follow me icons

Friday, September 30, 2011

Use '--expand' to expand Scenario outline tables in Cucumber output

The default cucumber options is to not expand the scenario outline table in the reporting. So when you run bundle exec features, it will print out the report like the one below:

Scenario Outline: Add two numbers
   Given I have entered "<num_1>" into the calculator
   And I press the add button
   And I have entered "<num_2>" into the calculator
   And I press the equal button
   Then the result should be "<result>" on the screen
  |num_1 | num_2 | result |
  | 1        |   1       |   2    |
  | 2        |   2       |   4    |
  | 3        |   5       |   8    |

In one way this is good because the report is concise and easily readable. However, one issue that I have is when there is an error in the scenario. Let say the error is on the "And I press the equal button", then you would not know it because it will not show which one is the error.

One way to overcome this is to use the "--expand" options from cucumber --help which will expand the scenario outline. I found this very useful when you have thousands of scripts running. This --expand option will give a much more verbose reporting.

Here is the result of running bundle exec --expand cucumber features:
As you can see, if the error occurs in the "And I press the add button" then cucumber will highlight it with red.

 Scenario Outline: Add two numbers                  
   Given I have entered "<num_1>" into the calculator
   And I press the add button                      
   And I have entered "<num_2>" into the calculator
   And I press the equal button                    
   Then the result should be "<result>" on the screen


     Scenario: | 1 | 1 | 2 |                  
       Given I have entered "1" into the calculator
       And I press the add button                
       And I have entered "1" into the calculator
       And I press the equal button              
       Then the result should be "2" on the screen

     Scenario: | 2 | 2 | 4 |                  
       Given I have entered "2" into the calculator
       And I press the add button                
       And I have entered "2" into the calculator
       And I press the equal button              
       Then the result should be "4" on the screen

     Scenario: | 3 | 5 | 8 |                  
       Given I have entered "3" into the calculator
       And I press the add button                
       And I have entered "5" into the calculator
       And I press the equal button              
       Then the result should be "8" on the screen


>bundle exec cucumber --help

Usage: cucumber [options] [ [FILE|DIR|URL][:LINE[:LINE]*] ]+

cucumber examples/i18n/en/features
cucumber @rerun.txt (See --format rerun)
cucumber examples/i18n/it/features/somma.feature:6:98:113
cucumber -s -i

    -r, --require LIBRARY|DIR        Require files before executing the features. If this
                                     option is not specified, all *.rb files that are
                                     siblings or below the features will be loaded auto-
                                     matically. Automatic loading is disabled when this
                                     option is specified, and all loading becomes explicit.
                                     Files under directories named "support" are always
                                     loaded first.
                                     This option can be specified multiple times.
        --i18n LANG                  List keywords for in a particular language
                                     Run with "--i18n help" to see all languages
    -f, --format FORMAT              How to format features (Default: pretty). Available formats:
                                       debug       : For developing formatters - prints the calls made to the listeners.
                                       html        : Generates a nice looking HTML report.
                                       json        : Prints the feature as JSON
                                       json_pretty : Prints the feature as prettified JSON
                                       junit       : Generates a report similar to Ant+JUnit.
                                       pdf         : Generates a PDF report. You need to have the
                                                     prawn gem installed. Will pick up logo from
                                                     features/support/logo.png or
                                                     features/support/logo.jpg if present.
                                       pretty      : Prints the feature as is - in colours.
                                       progress    : Prints one character per scenario.
                                       rerun       : Prints failing files with line numbers.
                                       stepdefs    : Prints All step definitions with their locations. Same as
                                                     the usage formatter, except that steps are not printed.
                                       usage       : Prints where step definitions are used.
                                                     The slowest step definitions (with duration) are
                                                     listed first. If --dry-run is used the duration
                                                     is not shown, and step definitions are sorted by
                                                     filename instead.
                                     Use --format rerun --out features.txt to write out failing
                                     features. You can rerun them with cucumber @rerun.txt.
                                     FORMAT can also be the fully qualified class name of
                                     your own custom formatter. If the class isn't loaded,
                                     Cucumber will attempt to require a file with a relative
                                     file name that is the underscore name of the class name.
                                     Example: --format Foo::BarZap -> Cucumber will look for
                                     foo/bar_zap.rb. You can place the file with this relative
                                     path underneath your features/support directory or anywhere
                                     on Ruby's LOAD_PATH, for example in a Ruby gem.
    -o, --out [FILE|DIR]             Write output to a file/directory instead of STDOUT. This option
                                     applies to the previously specified --format, or the
                                     default format if no format is specified. Check the specific
                                     formatter's docs to see whether to pass a file or a dir.
    -t, --tags TAG_EXPRESSION        Only execute the features or scenarios with tags matching TAG_EXPRESSION.
                                     Scenarios inherit tags declared on the Feature level. The simplest
                                     TAG_EXPRESSION is simply a tag. Example: --tags @dev. When a tag in a tag
                                     expression starts with a ~, this represents boolean NOT. Example: --tags ~@dev.
                                     A tag expression can have several tags separated by a comma, which represents
                                     logical OR. Example: --tags @dev,@wip. The --tags option can be specified
                                     several times, and this represents logical AND. Example: --tags @foo,~@bar --tags @zap.
                                     This represents the boolean expression (@foo || !@bar) && @zap.

                                     Beware that if you want to use several negative tags to exclude several tags
                                     you have to use logical AND: --tags ~@fixme --tags ~@buggy.

                                     Positive tags can be given a threshold to limit the number of occurrences.
                                     Example: --tags @qa:3 will fail if there are more than 3 occurrences of the @qa tag.
                                     This can be practical if you are practicing Kanban or CONWIP.
    -n, --name NAME                  Only execute the feature elements which match part of the given name.
                                     If this option is given more than once, it will match against all the
                                     given names.
    -e, --exclude PATTERN            Don't run feature files or require ruby files matching PATTERN
    -p, --profile PROFILE            Pull commandline arguments from cucumber.yml which can be defined as
                                     strings or arrays.  When a 'default' profile is defined and no profile
                                     is specified it is always used. (Unless disabled, see -P below.)
                                     When feature files are defined in a profile and on the command line
                                     then only the ones from the command line are used.
    -P, --no-profile                 Disables all profile loading to avoid using the 'default' profile.
    -c, --[no-]color                 Whether or not to use ANSI color in the output. Cucumber decides
                                     based on your platform and the output destination if not specified.
    -d, --dry-run                    Invokes formatters without executing the steps.
                                     This also omits the loading of your support/env.rb file if it exists.
    -a, --autoformat DIR             Reformats (pretty prints) feature files and write them to DIRECTORY.
                                     Be careful if you choose to overwrite the originals.
                                     Implies --dry-run --formatter pretty.
    -m, --no-multiline               Don't print multiline strings and tables under steps.
    -s, --no-source                  Don't print the file and line of the step definition with the steps.
    -i, --no-snippets                Don't print snippets for pending steps.
    -q, --quiet                      Alias for --no-snippets --no-source.
    -b, --backtrace                  Show full backtrace for all errors.
    -S, --strict                     Fail if there are any undefined or pending steps.
    -w, --wip                        Fail if there are any passing scenarios.
    -v, --verbose                    Show the files and features loaded.
    -g, --guess                      Guess best match for Ambiguous steps.
    -l, --lines LINES                Run given line numbers. Equivalent to FILE:LINE syntax
    -x, --expand                     Expand Scenario Outline Tables in output.
        --drb                        Run features against a DRb server. (i.e. with the spork gem)
        --port PORT                  Specify DRb port.  Ignored without --drb
        --version                    Show version.
    -h, --help                       You're looking at it.

Monday, July 18, 2011

cucumber - undefined method `line' for nil:NilClass (NoMethodError)

This error occurs when I run my cucumber test using the tag:

/test>bundle exec cucumber features\regression\simple_test -t @test

undefined method `line' for nil:NilClass (NoMethodError)
/test/vendor/ruby/1.8/gems/gherkin-2.3.6-x86-mingw32/lib/gherkin/formatter/filter_formatter.rb:64:in `examples'
/test/vendor/ruby/1.8/gems/gherkin-2.3.6-x86-mingw32/lib/gherkin/formatter/tag_count_formatter.rb:30:in `examples'
/test/vendor/ruby/1.8/gems/gherkin-2.3.6-x86-mingw32/lib/gherkin/listener/formatter_listener.rb:107:in `replay_step_or_examp
/test/vendor/ruby/1.8/gems/gherkin-2.3.6-x86-mingw32/lib/gherkin/listener/formatter_listener.rb:41:in `scenario_outline'
/test/vendor/ruby/1.8/gems/gherkin-2.3.6-x86-mingw32/lib/gherkin/parser/parser.rb:46:in `__send__'
/test/vendor/ruby/1.8/gems/gherkin-2.3.6-x86-mingw32/lib/gherkin/parser/parser.rb:46:in `method_missing'
/test/vendor/ruby/1.8/gems/gherkin-2.3.6-x86-mingw32/lib/gherkin/lexer/i18n_lexer.rb:23:in `scan'
/test/vendor/ruby/1.8/gems/gherkin-2.3.6-x86-mingw32/lib/gherkin/lexer/i18n_lexer.rb:23:in `scan'
/test/vendor/ruby/1.8/gems/gherkin-2.3.6-x86-mingw32/lib/gherkin/parser/parser.rb:31:in `parse'
/test/vendor/ruby/1.8/gems/cucumber-0.10.0/bin/../lib/cucumber/feature_file.rb:35:in `parse'
/test/vendor/ruby/1.8/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime/features_loader.rb:28:in `load'
/test/vendor/ruby/1.8/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime/features_loader.rb:26:in `each'
/test/vendor/ruby/1.8/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime/features_loader.rb:26:in `load'
/test/vendor/ruby/1.8/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime/features_loader.rb:14:in `features'
/test/vendor/ruby/1.8/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime.rb:132:in `features'
/test/vendor/ruby/1.8/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime.rb:45:in `run!'
/test/vendor/ruby/1.8/gems/cucumber-0.10.0/bin/../lib/cucumber/cli/main.rb:43:in `execute!'
/test/vendor/ruby/1.8/gems/cucumber-0.10.0/bin/../lib/cucumber/cli/main.rb:20:in `execute'
/test/vendor/ruby/1.8/bin/cucumber:19:in `load'

It turns out that cucumber (0.10) is not able to handle an empty scenario outline.

Scenario Outline: An Empty scenario outline example - Add Two Number
Given I have entered <num_1> into the calculator
And I press add
And I have entered <num_2> into the calculator
When I press add
Then the result <result> should be on the screen
|num_1 | num_2 | result |

The reason I have an empty scenario outline is for a placeholder.

If you run the cucumber without using the tag (e.g bundle exec cucumber features\regression\simple_test), then cucumber will run just fine.

The fix is to just add examples into scenario outline or to comment out the scenarios.

Friday, March 18, 2011

SOAP request in Cucumber using Savon Ruby Gems

Here is how I use Savon for my project:

To install/configure Savon:
1. gem install savon
2. add "require 'savon'" in your env.rb files


Scenario: Example of sending a soap request using Savon Gems
Given the user creates a new wsdl client

When the user sends a "findGeocodedAddress" request
|street_name | street_type | street_number | street_suffix |
|Burrows Road| S | 20/2 | UnDefined |
Then the user should get a success response
And findGeocoded response should have "11" addresses


Given /^the user creates a new wsdl client$/ do
@client = do
wsdl.document = ""

When /^the user sends a "([^\"]*)" request$/ do |request, table|
xml = find_geocoded_address_xml table.hashes[0]
@soap_response = @client.request :wsdl, request do |soap|
soap.body =!

#I am using Builder to generate my xml structure
def find_geocoded_address_xml address
xml = => 2)

return xml

Then /^the user should get a success response$/ do
@soap_response.success?.should == true
@soap_response.soap_fault?.should == false
@soap_response.http_error?.should == false

Then /^findGeocoded response should have "([^\"]*)" addresses$/ do |num_address|
addresses = @soap_response.to_array[0][:find_geocoded_address_response][:addresses]
@num_address_result = num_address.to_i
if addresses.class == Array
addresses.count.should == @num_address_result
#returns as a hash that means only one result
@num_address_result.should == 1

Wednesday, March 9, 2011


Early this week, I installed a new gem called capybara-firebug. This is a very useful gems. I have been wanting to enable firebug when running the test. Previously, I can pause my web test but I cannot inspect the web element as firebug is not enable. This capybara-firebug gems solve my problem and is very helpful to debug my web test.

For more information about capybara-firebug, please visit
Extract from the readme files:
capybara-firebug provides a dead-simple way to run scenarios with Firebug enabled under the selenium driver.

1. Install the gem
2. require 'capybara/firebug' in env.rb
3. Tag a scenario with @firebug
4. Run it

Please note that Capybara-firebug requires capybara version and cucumber 0.10.0.

Wednesday, March 2, 2011

Unable to obtain stable firefox connection in 60 seconds

I recently got this error message when running my cucumber test

unable to obtain stable firefox connection in 60 seconds ( (Selenium::WebDriver::Error::WebDriverError)
I have just installed Ubuntu 10 on my machine and then trying to setup my cucumber test. When I try to run my firefox from console I receive this weird errors:

None of the authentication protocols specified are supported.
2270:initable_init: assertion failed: (connection->initialization_error == NULL)

Finally, I found that I log in as a root and for some reason you can't fireup firefox as a root and therefore selenium webdriver also fails to obtain stable firefox connection.

To fix the issue, I just exit as a root and rerun my cucumber test.

Another solution is because you are running an older version of selenium webdriver and the old version does not support firefox version > 4x. To fix the issue either upgrade your selenium webdriver version or downgrade your firefox to version 3.6x

Monday, February 21, 2011

How to install ansicon for cucumber to get coloured output on Windows

Last week, I have just upgraded my cucumber gem from 0.6.4 into 0.10.0 as the documentation says that the new gem from 0.7 onward should be able to parse the gherkin text 50-100 times faster.

However, after I upgraded to version 0.10.0, I get the following warning

*** WARNING: You must use ANSICON 1.31 or higher 
( to get coloured output on Windows

I actually like the win32console better than this as you can just put the win32console gem into your gemfile so you don't have to install ansicon separately.

Anyway, here are the steps on how to install ansicon.exe:

1. Download and unzip the file from
2. open cmd and navigate to the unzipped folder
3. Navigate to x64 (if you have a 64 bit machine) otherwise navigate to x86
4. Type ansicon.exe -h and you will get the following:
D:\Data\ansicon\x86>ansicon.exe -h
ANSICON by Jason Hood .
Version 1.32 (22 December, 2010).  Freeware.

Process ANSI escape sequences in Win32 console programs.

ansicon -i|I | -u|U
ansicon [-m[]] [-p | -e|E string | -t|T [file(s)] | program [args]]

  -i            install - add ANSICON to the AutoRun entry (implies -p)
  -u            uninstall - remove ANSICON from the AutoRun entry
  -I -U         use local machine instead of current user
  -m            use grey on black ("monochrome") or  as default color
  -p            hook into the parent process
  -e            echo string
  -E            echo string, don't append newline
  -t            display files ("-" for stdin), combined as a single stream
  -T            display files, name first, blank line before and after
  program       run the specified program
  nothing       run a new command processor, or display stdin if redirected

 is one or two hexadecimal digits; please use "COLOR /?" for details.
5. Execute 'ansicon.exe -i' to install and add ansicon to your Windows
6. Run your cucumber 0.10.0 test and you should 
get the coloured output result on Windows

Friday, February 18, 2011

Installing and configuring Gembundler for Windows

This is how I install gem bundler for my test automation suites using Windows. My test project structure is similar with the one from this cucumber setup page

1. Go to your top level directory above the 'features' directory
2. Install gem bundler from the command prompt. Gem install bundler

D:\Work\ui>gem install bundler
Temporarily enhancing PATH to include DevKit...
Successfully installed bundler-1.0.10
1 gem installed
Installing ri documentation for bundler-1.0.10...
Installing RDoc documentation for bundler-1.0.10...


3. Create a gemfile in your current directory
Here is what my 'gemfile' looks like

source ""

group :test do
gem 'cucumber', '0.6.4'
gem 'rake', '0.8.7'
gem 'rspec', '1.2.8'
gem 'capybara', '0.4.0'
gem 'gizmo', '0.1.1'
gem 'win32-process', :platforms => [:mswin, :mingw]
gem 'win32console', :platforms => [:mswin, :mingw]
gem 'ruby-debug', '0.10.3' :platforms => [:ruby]

4. execute "bundle install --path vendor/bundle"

D:\Work\ui>bundle install --path vendor/bundle
Fetching source index for
Using rake (0.8.7)
Using activesupport (2.3.11)
Using builder (3.0.0)
Using celerity (0.8.8)
Using culerity (0.2.15)
Using mime-types (1.16)
Using nokogiri (
Using rack (1.2.1)
Using rack-test (0.5.7)
Using ffi (0.6.3)
Using childprocess (0.1.7)
Using json_pure (1.5.1)
Using rubyzip (0.9.4)
Using selenium-webdriver (0.1.3)
Using xpath (0.1.3)
Using capybara (0.4.0)
Using diff-lcs (1.1.2)
Using polyglot (0.3.1)
Using term-ansicolor (1.0.5)
Using treetop (1.4.9)
Using cucumber (0.6.4)
Using tilt (1.2.2)
Using gizmo (0.1.1)
Using rspec (1.2.8)
Installing win32-api (1.4.8) Temporarily enhancing PATH to include DevKit...

Installing windows-api (0.4.0)
Installing windows-pr (1.1.3)
Installing win32-process (0.6.5)
Installing win32console (1.3.0)
Using bundler (1.0.10)
Your bundle is complete! It was installed into ./vendor/bundle

5. Execute 'bundle exec cucumber features\whatever.feature' files

After installing gem bundler, you would need to run it using 'bundle exec' command. This ensure that cucumber will use the local gem file that you install under the vendor/bundler directories.

How to configure gemfile for windows platform

I use gem bundler for my test and in the past I only run it on Mac and therefore I didn't have to configure it to run in Windows. However, now I need to be able to run gem bundler in Windows, Ubuntu and Mac. This is because there are some gems that I specifically need to install only for Windows.

To configure your gemfile for windows platform, simply use the following syntax in your gemfile:

### windows specific gems ###
gem 'win32-process', :platforms => [:mswin, :mingw]
gem 'win32console', :platforms => [:mswin, :mingw]


### windows specific gems ###
platforms :mswin, :mingw do
gem 'win32console', '1.3.0'
gem 'wind32-process'

The documentation in says that mswin is for Windows but when I try just using "platform :mswin", it does not seem to work on my machine. That's why I add the "platform :mswin, :mingw".

Tuesday, February 8, 2011

Refresh Issue in Gizmo

I have been forced to use the 'sleep' method to wait for my page to load before I can check elements on the page as a temporary solution to my problem. The tests that I have been running somehow cannot get the element that I wanted. If I use the sleep method and wait for 1 - 2 seconds, then the test will be able to find that element. This is not an ideal solution. The automation test should be able to wait automatically until it can find the element on the page and we should not specify the time to wait.

I am currently using Gizmo, a page model testing framework, to dry up my testing assertion.

on_page_with :seo do |page|
page.seo_result_lists.should =~ /#{title}.*/

And inside the seo page I have the following code:

def seo_result_lists

The code above turns out to not give me the latest html content. The reason is because Gizmo is using Nokogiri to get the HTML content. When the page is initialized it will grab whatever html content it is currently loading. That is why my "@document.css("#navigation_listings").inner_text" returns nill instead of the text that I want.

One solution is to always 'Refresh' the page by assigning @document with the latest html content again "@document = Nokogiri::HTML(body)". However, this is not ideal because you have to refresh every time you want to get the value.

Another solution is to just not use the @document variable but to just use the capybara find method which will automatically wait until it finds the element to appear on the page. I eventually use this Capybara 'find' method over the @document.


def seo_result_lists

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 '' while accessing fatal: HTTP request failed

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

D:\>git clone
Initialized empty Git repository in
error: Couldn't resolve host '' while accessing

fatal: HTTP request failed

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

D:\>git clone
Initialized empty Git repository in
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.

Monday, January 10, 2011

Element is not currently visible and may not be manipulated

My web tests started to fail in Ubuntu when I upgraded my selenium-webdriver gem to the latest version 0.1.2.

Element is not currently visible and may not be manipulated (Selenium::WebDriver::Error::UnhandledError)
[remote server] :0:in `Error'
[remote server] file:///tmp/webdriver-profile20110110-17264-1osf9xy/extensions/ `'
[remote server] file:///tmp/webdriver-profile20110110-17264-1osf9xy/extensions/ `'
[remote server] file:///tmp/webdriver-profile20110110-17264-1osf9xy/extensions/ `'

The error does not explained alot but it seems that selenium-webdriver fails to locate the element. The code that I have is very simple which is to click the go button.

def click_go_button
find(:css, "#search_button").click

My test, however, works fine in a windows based environment. It only fails in the Linux environment.

So for now I have to gem uninstall selenium-webdriver 0.1.2 and gem install selenium-webdriver -v 0.0.29 to make my test work again in Ubuntu.

Friday, January 7, 2011

Cucumber Writing Standard

We found it useful to have a cucumber writing standard document where everyone can use it as a reference to write the scenarios. Without the standard we will have inconsistency in the features files.

1. The first cucumber writing standard that we have is to use a third person narrative when we write Given/When steps.

Given the user is on Google homepage
And the user clicks on the Google Search button

We find it more relevant to use "the user" instead of using the first person narrative "I"

2. We use "is/are" in the Given steps for assigning a variable.

Given price is "5" dollar
And quantity is "10"

And we use "should" in the Then steps for asserting result

Then the total price should be "50" dollar

This is so that we can differentiate quickly which one is the pre condition and which one is the assertion.

The above examples are the two things that are most argued in our team. Some people prefer to use "I" and some don't like to use the word 'should'. I guess there is no right or wrong answer. However, since we are working in a team, it is important that we come up with a cucumber writing standard so that we can have a consistent writing.

3. Condition statements (e.g if statements) are to be avoided in the scenario. This might sound obvious but for a tester who is new to cucumber might not find it that obvious.

Instead of

Given the user is on

Then the user should see his name if the user has signed in

We separate the scenarios into two lines

Scenario: User has signed in
Given the user is on

When the user signs in into his account as "bananta"
Then the user should see his name as "bananta"

Scenario: User has not signed in
Given the user is on
Then the user should not see "bananta"

4. Another standard that we have is that testers own/maintain the cucumber scenarios and the developers maintains the steps defintions. In other words, testers should not modify the steps definition and developers should not modify the test scenarios. This might sound obvious but in our case, the devs are modifying the scenarios without the testers' knowledge which cause the test cases to behave

We have more cucumber writing standards that are specific to our projects but the above examples are the main one that we have.