Difference between revisions of "Exploring your first cucumber project"
(Created page with "<div style="display: block; float:right; background-color: #FDFDFD; border: 1px #AFAFAF solid; padding: 10px;"> <categorytree mode=all depth=1>Web_Test_Automation_Tutorial</ca...") |
(No difference)
|
Revision as of 14:37, 23 May 2017
This is more of an informative part of the tutorial. If you don't feel like reading, you can skip to part 5: Exercises
Contents
Feature files
Let's start off by having a look at the feature files: ./features/example.feature
. You should see the following:
- Tags
@emaple
- a Feature
Feature: Example Feature
- A description of the feature
When I want (...) the tests below
- Multiple sceanrios
Scenario: example01 - Spritecloud search
- Steps
Given the user navigates to "blog"
Tags
A tag is used to be able to filter certain feature or scenario's when running your script in Cucumber. Try it out:
bundle exec cucumber -t @example # Will run the complete Feature: Example bundle exec cucumber -t @example01 # Will only run the first Scenario bundle exec cucumber -t @example -t ~@example01 # Will run all scenario's in the Example feature, except for the first one.
Feature, Scenario, Steps
A feature represents a major functionality of a website. This could be a single page or a functionality over multiple pages. Weather something actually is a separate feature is left to your own judgement. You don't want too much scenario's in 1 feature file, but also, you don't want too little. For example:
A product detail page
This could be a feature on itself with all the functionalities this page could have. Think of:
- Viewing the product image
- Adding an item to your basket
- Folding open a detailed description of the product.
Ordering a product
This is not a separate page, but more a flow that a user goes trough. Even though a part of this Feature is the product detail page, the complete flow of ordering a product goes trough multiple functionalities. In the end, on a feature like this, you would want to test specific order types, for example:
- Ordering 1 product with shipping cost
- Ordering multiple products, going over the free shipping threshold
- Ordering a product with a discount code
In a scenario, you will confirm 1 functionality. An often made mistake is to confirm multiple functionalities in 1 scenario. On large projects, this will ruin the maintainability of your test automation suite. In example.feature
you will see that every scenario just confirms 1 thing.
A step is the part that will actually execute your code.