3. Implement Feature File¶
Feature file is used to describe test scenario(s) in human readable language using Gherkin syntax. Artos accepts feature file(s) as an input and binds scenario steps to relevant method within the test project.
- Feature file is a text file with an extension
`.feature`
. - Script file should be placed inside
script
directory of the project.
3.1. Sample Feature File¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | Feature: Television Test
Background: User powers on Television
Given television is connected to power socket
WHEN television power is turned on
And television audio volume is to "50"
Then television displays "Television is ready for the test"
AND television "greed" LED is on
@smoke
Scenario Outline: Television Remote Functions works
Given remote button "<FunctionButtons>" is pressed
Then television displays "<ExpectedAction>"
Examples:
| FunctionButtons | ExpectedAction |
| ON | television is already ON |
| MUTE | television audio is muted |
| OFF | NA |
| ON | television is turned ON |
@smoke @manual
Scenario Outline: Volume check
Given television power is turned on
And television is configured
| brightness | pixel | input | headphone | externalSpeaker |
| 100 | <resolution> | HDMI | off | true |
When remote button "<FunctionButtons>" is pressed
Then User validates "<ExpectedAction>"
Examples:
| FunctionButtons | ExpectedAction | resolution |
| VolumeIncrease | Is volume higher by one? | HD |
| VolumeDecrease | Is volume lower by one? | FULL_HD |
|
3.2. Feature File Components¶
3.2.1. Feature¶
- Declared using
Feature:
followed by description of the the feature - Only one
Feature:
can be available in one feature file
1 | Feature: Television Test
|
3.2.2. Scenario¶
Scenario is declared using
Scenario Outline:
followed by description of the scenario.One feature file can have one or more scenarios.
Scenario is defined using Gherkin Syntax which utilizes keywords “Given”, “When”, “And”, “Then”
Scenario lines declared with Gherkin keywords are called Steps.
Scenario can be attached to one or more groups by adding group name above
Scenario Outline:
as shown in below example.Same scenario can be executed multiple time with various data by declaring example table as shown below.
- Declare wild card within step definition by using
"<wildcard>"
syntax. - Provide a table of data which maps to the wild card.
- First row of the each column maps the wild card.
- During execution wild card text is replaced by text from the table.
- Scenario will be executed repeatedly until all rows of the table is exhausted.
- Declare wild card within step definition by using
1 2 3 4 5 6 7 8 9 10 11 12 13 | @smoke @regression
Scenario Outline: Television Remote Functions works
Given television is on
And remote battery is fully charged
When remote button "<FunctionButtons>" is pressed
Then television displays "<ExpectedAction>"
Examples:
| FunctionButtons | ExpectedAction |
| ON | television is already ON |
| MUTE | television audio is muted |
| OFF | NA |
| ON | television is turned ON |
|
3.2.3. Background¶
- Declared using
Background:
followed by description of the background scenario - feature file can have only one
Background:
scenario. - Scenario declared under
Background:
is executed prior to each scenarios declared underScenario Outline:
Background:
is declared as very first scenario in feature file.
1 2 3 4 5 6 | Background: User powers on Television
Given television is connected to power socket
WHEN television power is turned on
And television audio volume is to "50"
Then television displays "Television is ready for the test"
AND television "greed" LED is on
|