I have a setup Maven+JUnit5+Selenium, my pom.xmlhttps://github.com/13Dima13/G/blob/master/pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<forkCount>4</forkCount>
<reuseForks>false</reuseForks>
<properties>
<includeTags>${tag}</includeTags>
</properties>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit.platform.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-logger-api</artifactId>
<version>${surefire-logger-api}</version>
</dependency>
</dependencies>
</plugin>
First i thought that @Tag works fine, because when i put an annotation to my class https://github.com/13Dima13/G/blob/master/src/test/java/com/example/project/TestThreads2.java
@Test
@Tag("smoke")
public void test1() {
open("https://mvnrepository.com/artifact/log4j/log4j/1.2.17");
$("#maincontent > table > tbody > tr:nth-child(1) > th").waitUntil(Condition.appears, 120000);
$("#maincontent > table > tbody > tr:nth-child(1) > th").shouldBe(Condition.text("License"));
assertEquals("Maven Repository: log4j » log4j » 1.2.17", title());
out.println("test1 Passed");
}
and then ran from terminal
mvn test -Dtag=smoke
it executed only the tests which were marked as @Tag("smoke"), so in my case only one test and this made me happy.
But when I started to use it on my real project I realized that it does not work sometimes.
For example, if my Test.class with tests methods is not placed in the parent project folder (for example inside child of project folder) https://github.com/13Dima13/G/blob/master/src/test/java/com/example/project/test2/GoogleSearch.java, annotation will not work at all.
So annotation @Tag doesn't work for the whole project or did I miss something?
Good example https://ibb.co/gjbSZJ