I have a test project that runs e2e tests and until now I built a .jar file, upload it to a test environment and then executed the tests against a test environment. The tests run serenity with cucumber. I would like to migrate the project now to junit5. The tests are started in a main method like this:
public static void main(String args[]) throws IOException {
Launcher launcher = LauncherFactory.create();
SummaryGeneratingListener summaryGeneratingListener = new SummaryGeneratingListener();
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
.selectors(selectClass(AllTests.class))
.build();
launcher.execute(
request,
summaryGeneratingListener);
boolean wasSuccessful = summaryGeneratingListener.getSummary().getFailures().isEmpty();
HtmlAggregateStoryReporter reporter = new HtmlAggregateStoryReporter("default");
File reportTarget = new File("target");
reporter.setOutputDirectory(reportTarget);
reporter.setGenerateTestOutcomeReports();
reporter.generateReportsForTestResultsFrom(reportTarget);
if (!wasSuccessful) {
System.exit(1);
} else {
if (isAutomaticRetryThresholdBreached()) {
System.exit(1);
}
System.exit(0);
}
}
This code executes the tests but does not generate a HTML report with serenity.
I managed to generate serenity reports with maven-surefire-plugin, but I would like to run tests as a jar. Do you know how to edit this code so that it generates a report?
I solved it with using the main method from serenity-cucumber.jar file. Here the example:
}