follow me icons

Thursday, January 27, 2011

Cucumber Parse Error, Expected one of \n \r

My cucumber tests usually have two sections, .manual and .feature, files. I use cucumber to write my automated test cases as well as the manual test cases. This way all of my test cases can be accessed from one project and you can easily differentiate which features are automable and which do not.

The good thing with cucumber is that it will only run the files that have .feature on it and ignoring the rest.

The way I run my test is usually by running the whole folder which is something like this:

cucumber features\regression


inside that folder I will have a mix of .manual and .feature files and folders.

Recently, I have been getting this error when I run my cucumber tests.

features/regression/postcode_details.feature:5:1: Parse error, expected one of "\n", "\r", "|", "\"\"\"", "#", "* ", "Given ", "When ", "Then ", "And ", "But ", "
@", "Scenario", "Scenario Outline". (Cucumber::Parser::SyntaxError


I check the feature file and everything looks ok. It actually took me a while to figure out that the mistake was just because I accidentally named a .manual file into a .feature file and thus the error as cucumber could not understand how to run a manual test. What an annoying mistake to make!

Monday, January 24, 2011

How to enable Ruby-debug in RubyMine

After finding out how to run my cucumber test through RubyMine, I try to enable the ruby-debug from RubyMine as well. It turns out that I need to install another ruby gem called Ruby-debug-ide which for some reason I could not download it straight from the RubyMine ide.

So here are the steps to install ruby-debug-ide gems into RubyMine:

1. Open your console, and type 'gem install ruby-debug-ide'
2. Open RubyMine and click File->Settings->Ruby SDK and Gems
3. Click Attach gems and attach 'ruby-debug-base'. You will need to instal 'ruby-debug' gems first.
4. Click Attach gems and attach 'ruby-debug-ide'
5. Click ok and put a breakpoint in your step definition

Thursday, January 20, 2011

error: Couldn't resolve host 'github.com' while accessing fatal: HTTP request failed

I am using Msygit 1.7.0.2 on my Windows machine. When I try to git clone a repository in github, I receive the following error


D:\>git clone
https://github.com/giozom/Cucumber-Test-Framework-for-Newbies.git
Initialized empty Git repository in
D:/Cucumber-Test-Framework-for-Newbies/.git/
error: Couldn't resolve host 'github.com' while accessing
https://github.com/giozom/
Cucumber-Test-Framework-for-Newbies.git/info/refs

fatal: HTTP request failed


It turns out I can get the clone to work by using http instead of https


D:\>git clone
http://github.com/giozom/Cucumber-Test-Framework-for-Newbies.git
Initialized empty Git repository in
D:/Cucumber-Test-Framework-for-Newbies/.git/
remote: Counting objects: 22, done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 22 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (22/22), done.


I am not really sure why git clone 'https://' does not work on my Windows machine but I am guessing it's because I don't have a github account.

Wednesday, January 19, 2011

Running cucumber test through RubyMine

I have been running my cucumber test using a command line console. I am so used to running it from the console that I did not bother to figure out how to run the cucumber test through the RubyMine ide. However, I was shown by my colleque on how to set it up:

From RubyMine you would need to do the following:
1. Click on File->Settings
2. Click on Ruby SDK and Gems
3. Click on Attach Gems
4. Locate your Cucumber gems and attach it.
5. Click Ok

Next is to configure your cucumber test environment variables.

1. Click on Run->Edit Configurations
2. Add the environment variables on the Environment Variables field

You can also specify which test you want to run on the "Feature file" field.

After that, all you need to do is to click the Run (Shift + F10) button to run your cucumber test from RubyMine.