I want to run selenium tests only if a special flag is provided e.g.
mvn -DrunUiTests=true test
I am using Junit5. I tried already:
- An env varible. But the tests will be instantieted anyway.
- An home made annotation
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(DisableUITests.class)
public @interface UITest { }
Where DisableUITests returns ConditionEvaluationResult.enabled if a env variable is set. But maven run on console ignores that annotationn.
Furthermore it tryied the surefire plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<excludes>
<exclude>**/*UiTest.java</exclude>
</excludes>
</configuration>
</plugin>
But then I am not able to start the tests my own :-)