This is an example BDD test automation Project for Java using the Cucumber-JVM framework. It contains a simple behavior scenario that performs a basic Google search.
This project was developed by Automation Panda to demonstrate how to use Cucumber-JVM as a BDD test framework.
This project uses Cucumber-JVM 2.0. If using IntelliJ IDEA, please make sure to update to the latest version of the Cucumber for Java plugin. Delete any old Run Configurations if updating, as well.
This project uses Selenium WebDriver to interact with the Chrome web browser. In order for the tests to work, ChromeDriver must be installed on the test machine and accessible from the system PATH. (This means that it must be accessible from the command line.)
The source code may easily be changed to work with any other web browser. Just remember to install the required web drivers.
This project uses Maven. To run tests, simply run "mvn clean test".
To practice BDD and automation, try the following exercises:
- The assertion for the "results for ___ are shown" step checks only the page title. Add more comprehensive assertions to strengthen the test.
- Add a new scenario to search Google for images.
- Add a new scenario to perform Google searches directly using URL query parameters.
- Add a new feature for basic tests against Wikipedia using a new page object class,
a new step definition class, and dependency injection.
- Picking a language from the home page.
- Searching for articles.
- Verifying that embedded links navigate to the correct articles.
- Viewing page history.
- Make it possible to choose the web browser using a properties file. Classes to read the properties file and construct the appropriate web driver should be put in the framework package.
- Write a new feature for basic service-level testing. Use REST Assured to hit a few endpoints from JSONPlaceholder.
- Create separate test runners that partition the set of features using tags.
- Add logging to the tests with SLF4J or Extent Reports.