Debug Serenity BDD JBehave project
Debug Serenity BDD JBehave project
In this post, we will learn how to debug a Serenity BDD JBehave project in case of test errors, failures, and exceptions. Note that, this post outlines steps to find the root cause that helps automation beginners in the Serenity project.
Serenity BDD Project was set up using the steps: Install Serenity BDD project using Maven.
Tools used:
- JDK.
- Eclipse IDE.
- Maven.
- Serenity BDD.
- JBehave.
- Selenium WebDriver.
Errors and exceptions in Serenity Project:
Let’s say you are performing a dry run in your IDE. Check the console for the exceptions and stack trace. The first thing you notice is the maven console log build failure.
A couple of locations where you can find the errors and exceptions are.
1. You can find the exceptions in Maven build console as shown below:
Serenity Reports
2. Serenity story reports under the folder :
{PROJECT_HOME}\target\site\serenity –> index.html
The common indication of some automation project issues or environmental issues is that you would see a high number of failures in the stories.
Click on the story that has failed.
Drill down to the step where the error has occurred.
Click the View Stack trace button.
Root cause
net.thucydides.core.webdriver.UnsupportedDriverException: Could not instantiate class org.openqa.selenium.firefox.FirefoxDriver Exception
This exception is caused when the browser driver is not present , or unsupported version is being used , or some anti virus protected Firefox to be launched etc.
Check maven pom.xml properties , serenity.properties for the version or which browser you are running the tests on. In most cases replace the driver with the latest version from the official Selenium website.
Fix the Error
Let’s replace the Firefox gecko driver with the latest version. After the fix re-run the serenity tests. The fix worked and tests have run.
In long run of the project, you can actually take hints from the failures in the tests, Jenkins CI pipeline, recent changes etc.. for finding the root causes. For example,a huge spike in automation failures would point an environmental issue, project issue etc.
On the other hand, isolated one or two story failures, you may need to look at the automation code steps, business logic , story verification behavior etc, .
JBehave Tutorials on this website can be found at:
https://www.testingdocs.com/jbehave-framework-tutorial/
For more details on the JBehave framework, visit the official JBehave website at:
http://jbehave.org