When I run a single test in Maven with this command:
mvn test -Dtest=InitiateTest
I'm getting the following result:
No tests were executed!
It worked a couple of minutes ago, but now it stopped working for some reason. I tried running mvn clean
a couple of times before running the test, it doesn't help.
The test looks like this:
import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.Select; import org.junit.After; import org.junit.Before; import org.junit.Test; public class InitiateTest { public static FirefoxDriver driver; @Before public void setUp() throws Exception { driver = new FirefoxDriver(); } @Test public void initiateTest() throws Exception { driver.get("http://localhost:8080/login.jsp"); ... } @After public void tearDown() throws Exception { driver.close(); } }
UPDATE:
It's caused by adding this dependency to POM:
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium</artifactId> <version>2.0b1</version> <scope>test</scope> </dependency>
When I remove it, everything works fine. Everything works fine even when I add these two dependencies instead of the previous one:
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-support</artifactId> <version>2.0b1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-firefox-driver</artifactId> <version>2.0b1</version> <scope>test</scope> </dependency>
This is weird.
The Maven surefire plugin provides a test parameter that we can use to specify test classes or methods we want to execute. If we want to execute a single test class, we can execute the command mvn test -Dtest=”TestClassName”.
Prior to these releases, to run JUnit 5 tests under Maven, you needed to include a JUnit provider dependency for the Maven Surefire plugin. This is correct for pre 2.22. 0 releases of Maven Surefire/Failsafe.
Perhaps you are seeing this bug, which is said to affect surefire 2.12 but not 2.11?
You are probably picking up JUnit3 on your classpath somewhere, which effectively disables JUnit4.
Run mvn dependency:tree to find out where it's coming in from and add an exclude to the dependency.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With