Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

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>

closed

1 Answer

+1 vote
by (62.9k points)
selected by
 
Best answer

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 from and just add an exclusion statement like shown below for it and tests should work:

<dependency>

  <groupId>org.seleniumhq.selenium</groupId>

  <artifactId>selenium</artifactId>

  <version>2.0b1</version>

  <exclusions>

    <exclusion>

      <groupId>org.testng</groupId>

      <artifactId>testng</artifactId>

    </exclusion>

  </exclusions>

</dependency>

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...