Issue
I want to run particular scenario from my feature file with the below command.
mvn test -Dcucumber.options="--tags @Smoke-Login"
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<encoding>UTF-8</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<includes>
<include>**/TestRunner.java</include>
</includes>
<parallel>methods</parallel>
<threadCount>4</threadCount>
<useUnlimitedThreads>false</useUnlimitedThreads>
</configuration>
</plugin>
</plugins>
</build>
</project>
The below is my runner file for running the suite from pom.xml
@RunWith(Cucumber.class)
@CucumberOptions(
publish = true,
features = "classpath:features",glue = "stepDefinations",
plugin = {"junit:target/cucumber-results.xml","rerun:target/rerun.txt",
"pretty",
"json:target/cucumber-reports/CucumberTestReport.json"},
tags="@QA53",
monochrome = true
)
public class TestRunner {
@BeforeClass
public static void setup(){
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("mac")) {
PropertyConfigurator.configure(System.getProperty("user.dir")+"/src/test/resources/log4j.properties");
}
else {
PropertyConfigurator.configure(FileReader.getInstance().getConfigReader().getlog4jpath());
}
}
@AfterClass
public static void writeExtentReport() {
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("mac")) {
}
else {
}
}
}
Here is my file structure in the below image.
Solution
If you are on a recent version of Cucumber (> 5.0) the syntax is cucumber.filter.tags=@Smoke-Login
.
Answered By - M.P. Korstanje