A library that contains the glue code and the necessary instructions for using webdriver-framework-core with the JUnit5 hooks. This library also contains JUnit5 specific code for managing the lifecycle of the WebDriver with Test Method.
This is the JUnit5 specific framework library intended to be used by developers who are using JUnit5 as their Testing framework. The steps to include this into your code is as follows,
- Add the library dependency to your pom.xml.
<dependency>
<groupId>com.browserstack</groupId>
<artifactId>webdriver-framework-junit5</artifactId>
<version>LATEST</version>
</dependency>
- Create Webdriver Test: Create your test methods with Webdriver as a parameter.
public class SampleTest {
public void test (WebDriver webDriver) {
...
}
}
- Annotate your tests with @WebDriverTest Annotations: This will inject Webdrivers based on your configuration files.
public class SampleTest {
@WebDriverTest
public void test (WebDriver webDriver) {
...
}
}
- To ensure that the WebDriver instances are stopped when the test is completed, a Test Watcher is provided as part of this library
The TestWatcher class is responsible for,
-
Marking the tests as pass/fail along with the appropriate error messages.
-
Quitting the WebDriver instance such that the test session on BrowserStack also is ended cleanly.