-
Notifications
You must be signed in to change notification settings - Fork 44
Creating Cucumber Tests
jyotsna-tarento edited this page Jul 25, 2018
·
4 revisions
-
Create a .feature file with the below information.
- A line starting with the keyword Feature followed by a statement indicating the purpose of the test
- Multiple scenarios which are also statements starting with the keyword Scenario followed by a line specifying the scenario or different scenarios for the test
- Under each scenario statement, steps are created using the keywords Given, When and Then
- Given - Statements beginning with the keyword Given, and used to specify test assumptions or validations
- When - Statements beginning with the keyword When, and used to specify the key action that the scenario achieves
- Then - Statements beginning with the keyword Then, and used to specify the outcome of the scenario
-
Create a java class in which the features, scenarios and steps mentioned above are implemented. An example can be found here.
-
Create a test class with a sample format as given below. The keyword features is used to specify paths of .feature files and glue keyword is used to specify paths of steps files.
@RunWith(Cucumber.class)
@CucumberOptions(features = "", glue = {""})
public class SampleTest {
}
- When this test class is executed, it picks up the feature files and classes which contains the steps implementation based on the path specified and executes them.