6

Hello I'm trying to run a JUnit test using Maven.

public final class CreateAllObject {
    public static final String INIT_URL = new String("http://fpt2:8080/webTest/");

    @BeforeClass
    public static void initialisation() {
        Driver driver = new Driver(PROFILE_PATH);
        driver.getDriver().get(INIT_URL);
        driver.getDriver().findElement(By.xpath(ADMIN_ARM_XPATH)).click();
        BASE_URL = driver.getDriver().getCurrentUrl();
        driver.getDriver().close();
        try {
            new File("C://logfiles//").mkdirs();
            log_work = new BufferedWriter(new FileWriter(new File("C://logfiles//"
                    + new SimpleDateFormat("dd.MM.yyyy 'at' HH-mm-ss").format(new GregorianCalendar().getTime())
                    + ".log_work")));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void test() {
        Driver driver = new Driver(PROFILE_PATH);
        // ...
    }

    @AfterClass
    public static void destruction() {
        try {
            log_work.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

After running command mvn test in the project's base directory I'm getting this :

[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ uitests-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ uitests-core ---
[INFO] Surefire report directory:
       /var/opt/jenkins/workspace/platform-ui-tests/core/target/surefire-reports

-------------------------------------------------------  
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

I don't know why it doesn't run my test. Help me please.

zb226
  • 9,586
  • 6
  • 49
  • 79
Ghostleg
  • 161
  • 1
  • 2
  • 10
  • possible duplicate of [Maven does not find JUnit tests to run](http://stackoverflow.com/questions/6178583/maven-does-not-find-junit-tests-to-run) – Ajinkya Jul 04 '14 at 10:03

1 Answers1

5

Maven looks for tests named *Test, Test*, or *TestCase by default. You can configure it to run classes with other names, but it's much better to follow the conventions if you don't have a compelling reason not to. Rename your class to something that starts or ends in Test and give it another try.

See this answer: Maven does not find JUnit tests to run as well.

Community
  • 1
  • 1
rpmartz
  • 3,759
  • 2
  • 26
  • 36