Open TheGlovner opened 1 year ago
I've tried some further changes with the runner class based on things I've found online, so it's new configuration looks like this, but still the same result of "No tests were found":
package swaglabs;
import net.serenitybdd.junit5.SerenityJUnit5Extension;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.platform.suite.api.ConfigurationParameter;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.platform.suite.api.SelectClasspathResource;
import org.junit.platform.suite.api.Suite;
import static io.cucumber.core.options.Constants.GLUE_PROPERTY_NAME;
import static io.cucumber.core.options.Constants.PLUGIN_PROPERTY_NAME;
@Suite
@ExtendWith(SerenityJUnit5Extension.class)
@IncludeEngines("cucumber")
@ConfigurationParameter(key=PLUGIN_PROPERTY_NAME , value = "pretty")
@SelectClasspathResource("src/test/resources/features/")
@ConfigurationParameter(key=GLUE_PROPERTY_NAME , value = "swaglabs/stepdefinitions")
public class TestRunner {}
It is not easy to figure this out, but I use the dependencies from here: https://serenity-bdd.github.io/docs/guide/maven#cucumber-with-junit-5-dependencies
And can you also try this ConfigurationParameter -> SerenityReporter? @TheGlovner
import org.junit.platform.suite.api.ConfigurationParameter;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.platform.suite.api.SelectClasspathResource;
import org.junit.platform.suite.api.Suite;
@Suite
@ConfigurationParameter(key = "plugin", value = "io.cucumber.core.plugin.SerenityReporter")
@IncludeEngines("cucumber")
@SelectClasspathResource("/features")
public class CucumberTestSuite {
}
I hope this helps.
This is a JUnit 5 configuration issue of some kind.
@SelectClasspathResource does not work in Linux for junit platform engine. Workaround is to use FEATURES_PROPERTY_NAME
I tried the snippet below, It picks all the scenarios defined on the feature file irrespective of whether they have a @smoke tag. I am using the following versions: Serenity - 4.1.12 Cucumber - 7.13.0 JUnit - 5.10.0 maven-surefire - 3.0.0-M5 maven-failsafe - 3.3.0 maven-compiler - 3.8.1
package Runner;
import org.junit.platform.suite.api.ConfigurationParameter; import org.junit.platform.suite.api.IncludeEngines; import org.junit.platform.suite.api.SelectClasspathResource; import org.junit.platform.suite.api.Suite;
import static io.cucumber.junit.platform.engine.Constants.*;
@Suite @IncludeEngines("cucumber") @ConfigurationParameter(key = FEATURES_PROPERTY_NAME, value = "classpath:Features") //@SelectClasspathResource("Features") // Adjust this to your actual feature file location @ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "@smoke") @ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "StepDefinitions") // Adjust to your step definitions package @ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty,html:target/cucumber-html-report,summary") public class TestRunnerSerenity { }
Hopefully someone has already solved this.
I'm trying to get a Serenity Cucumber project running using Junit5.
Issue is two fold, when using
mvn clean verify
it doesn't seem to find any tests regardless of the following configurations.If I'm running directly from the TestRunner class configured for Junit4 it can see the tests fine, but when I switch the annotations over to the Juni5 ones then it can't see any of the feature files and instead runs the process and returns "No tests were found".
This test runner will allow me to run directly from the runner and find the feature file:
But when I switch over to the following I get the "No tests were found" message:
Here is the serenity.conf (although I don't think there is anything in here impacting things):
And my current POM.xml setup:
Fingers crossed someone else has this working and can see what I'm clearly missing.