Checkbook BDD Testing with Serenity, Cucumber and Selenium
- Java SDK 1.8
- Maven
- driver for phantomJS or chrome
- Cucumber plugin for Eclipse or Cucumber plugin for IntelliJ
Follow the below steps to implement cucumber test
- Create feature file with scenario(s) under src/test/resources/features folder in Given, When, And, Then format. Refer to Cucumber documentation on how to write scenarios
- Create a step implementation class. The Steps in the scenario from the feature file are linked to the method using annotations @Given, @When, @Then and @And. Extend io.reisys.checkbook.bdd.common.CheckbookBaseScenarioSteps. Steps common between feature files can be added to CheckbookBaseScenarioSteps.
- Implement a Page object class. Extend io.reisys.checkbook.bdd.common.CheckbookBasePageObject to get access to WebDriver and ExecutionContext that provides the data from the json files
- Create json file for data under src/test/resources/data folder
- Create Runner file and provide the json file as @TestDataFile to use in the runner
- Update serenity.properties to set the browser to use for running tests
- Update serenity.properties to set the site url for running tests
- Run the appropriate runner class as Junit test.
- Run goals clean verify serenity:aggregate
- To run only specific runner update the runner name in pom.xml. Its currently set to run all the Runners.
- Either update serenity.properties to set the parameters or provide them as parameters
- e.g) mvn clean verify serenity:aggregate -Dwebdriver.driver= -Dwebdriver.base.url= -Ddatabase.connection.url= -Ddatabase.user= -Ddatabase.password=