I'm having trouble compiling and running JUnit tests using a maven project.
In the pom.xml I added those lines to configure the surfire plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<encoding>UTF-8</encoding>
<skipTests>false</skipTests>
<includes>
<include>**/*.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>unit-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include>**/Client*.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
the tests classes are under the path "src/test/java//".
When I run the command mvn test
I obtain this output:
[INFO] Storing buildScmBranch: trunk
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 10 resources
[INFO] [cxf-codegen:wsdl2java {execution: generate-sources}]
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[INFO] Not copying test resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Not compiling test sources
[INFO] [surefire:test {execution: default-test}]
[INFO] Tests are skipped.
[INFO] [surefire:test {execution: unit-test}]
[INFO] No tests to run.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)
I really can't figure out where I'm wrong.
EDIT: I changed the pom configuration as follows, because I also noticed that the tests classes were also not compiled:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
<executions>
<execution>
<id>default-testCompile</id>
<configuration>
<source>1.6</source>
<target>1.6</target>
<skip>false</skip>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}/target/*.jar</additionalClasspathElement>
</additionalClasspathElements>
<directory>${basedir}/src/test/java</directory>
<includes>
<include>**/*.*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
In this way maven start to consider my test sources and try to compile it, even if it fails to compile them because I have generated code with cxf-codegen-plugin, that test compilation seems not to see it.