Creating a ruby project architecture in Integrate Eclipse Editor With Cucumber:
- Install eclipse, ruby, cucumber in your system.
- Open eclipse editor.
- Go to file menu click properties then copy the location or path in the command prompt.
- Write cucumber—init.
- It generates all the feature files and step definition files.
- Go to the eclipse again refresh the file then we can see the feature files and step definition files.
- In feature we write feature file and step definition files.
Cucumber Tags:
In this testing tool we have got many feature files which covers all the different functionality of the application. Suppose there may be a situation in the project where you like to execute just a Smoke tests or End2End tests or may be regression tests, For which we may need more maintenance. Cucumber has a solution to organise the scenario execution by using a useful tag.
Tag starts with “@” symbol followed by a text which is relevant. Then to target these scenarios by specifying the tag names in the cucumber options as tags={“@SmokeTests”}. Tags are user defined and any name can be given like @smoke, @regression.
Cucumber feature file tag usage in Java:
Consider the example with a scenario
@tag1
Scenario: Title of your scenario
Given we want to write a step with precondition
And some other action
And yet another action
Then validate the outcomes
And check more outcomes
@tag2
Scenario outline: title of your scenario outline
Given I want to write a step with <name>
When I check for the <value> in step
Then I verify the <status> in step
Examples
| Name | value | status |
| name1 | 5 | success|
| name2 | 7 | fail |
What are different types of tags?
There are three different types of tags:
- Feature level tag
- Scenario tag
- Example level tag
In above example, the first line consists of feature with 2 tags first feature and regression. All other scenarios can be executed from this feature file.
This scenario 1 is tagged in smoke test when we want to run only first scenario then we can create a unique tag name like @tag11.
We can update in our testRunnerclass.java.It will run only that scenario.
Suppose we have created one more feature file with the scenarios 1 and 2 defined and the scenario 2 consists the same tag name of first scenario in first feature file then all the scenarios with the same name is executed from the testRunnerclass.java. Even if those scenarios have been defined from the different feature files.
Here in this we have a requirement to run Smoke scenario so we are using one more tag called @smoke and when we update the testRunnerclass.java with @smoke then all scenarios with smoke will be executed.
If we have to run all the scenarios in the feature files then update the testRunnerclass.java with a tag defined in firstfeature file i.e @regression then all scenarios will run from the feature file defined at the beginning of the project.
Next is using example level tag @dev tag and @sit tag
Example level tags are used when we have multiple environment or we have to execute particular scenario with the particular set of data in particular environment.it can be run from testRunnerclass.java by updating it with respective tags.