This plugin allows executing Java based JUnit tests using the CloudBeat platform.
git clone https://github.com/oxygenhq/cb-framework-plugin-junit
cd cb-framework-plugin-junit
mvn install
Add the plugin to your project. If you are using a maven based project, you can directly add this library as a dependency:
<dependency>
<groupId>io.cloudbeat.framework</groupId>
<artifactId>cb-framework-junit5</artifactId>
<version>0.1.0</version>
</dependency>
For running multiple chosen tests install maven surefire plugin with version equal or higher then 2.22.0
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</build>
When using Selenium it might be beneficiary to be able to take browser screenshots in case of failures. This can be achieved in a two different ways. Please note that all 2 options are mutually exclusive.
- By providing WebDriver instance to the plugin.
- By providing WebDriver getter method to the plugin.
public class YourExtension implements BeforeAllCallback, ExtensionContext.Store.CloseableResource, JUnitRunner {
@Override
public void beforeAll(ExtensionContext context) {
WebDriver driver = ... // WebDriver initialization
setWebDriver(driver);
}
}
public class YourExtension implements BeforeAllCallback, ExtensionContext.Store.CloseableResource, JUnitRunner {
@Override
public void beforeAll(ExtensionContext context) {
WebDriverProvider provider = new WebDriverProvider();
setWebDriverGetter(provider::getWebDriver);
}
}
public class WebDriverProvider {
public WebDriver getWebDriver() {
return driver;
}
}
And then in both cases before each class add this code:
@ExtendWith({YourExtension.class})