mardi 15 novembre 2016

How to use surefire plugin to run test in customized folder structure

I have a customized eclipse studio project. For unit testing we are creating a test file under -

  TestJavaSrc/demoTest.java

Now this TestJavaSrc folder is on the same level as of POM.xml Here is POM.xml -

 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.demo.test</groupId>
    <artifactId>demo</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
            </plugin>
        </plugins>
    </build>
</project>

Now when I run this project as mvn test , it is not able to find any test files. And also , when I run following command on command line -

 mvn "-Dtest=TestJavaSrc/DemoTest.java" test

It gives me error-

 Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test
 (default-test) on project demo: No tests were executed! 
 (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]

Also , I have JUnit4 in my classpath

Is there anything I am missing?

Aucun commentaire:

Enregistrer un commentaire