0

When built from eclipse the test classes are generated under target/test-classes however this is empty (only the test resources are copies but no test classes ) when I run

mvn clean install

I see the following messages

[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile)
@ core --- [WARNING] File encoding has not been set, using platform
encoding US-ASCII, i.e. build is platform dependent! [INFO] Compiling
46 source files to
/Users/root/Perforce/Server/DL/Server/dev/core/target/test-classes
[INFO]  [INFO] --- maven-surefire-plugin:2.17:test (default-test) @
core ---

Wondering where did those classes go. When I ran

mvn -X install

I saw

[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile)
@ core --- [WARNING] File encoding has not been set, using platform
encoding US-ASCII, i.e. build is platform dependent! [INFO] Compiling
46 source files to
/Users/root/Perforce/Server/DL/Server/dev/core/target/test-classes
[INFO]  [INFO] --- maven-surefire-plugin:2.17:test (default-test) @
core ---

[DEBUG] Output directory:
/Users/root/Perforce/Server/DL/Server/dev/core/target/test-classess
[DEBUG] CompilerReuseStrategy: reuseCreated [DEBUG]
useIncrementalCompilation enabled [DEBUG] Stale source detected:
/Users/root/Perforce/Server/DL/Server/dev/core/src/test/java/test/datastore/FileTest.java

And all other files.

Please suggest any way to debug further why the compiled test classes are not present so that the tests can be run in the next phase.

Note that this is a sub project under a parent project and all other subproject's tests classes are compiled and run but not this one. Strange the parent POM has all the settings so not sure whats special about this

Neil
  • 5,919
  • 15
  • 58
  • 85
  • did you refresh your target folder after doing the build and have you enabled tests to be run when you do the mvn clean install – vikeng21 Sep 30 '14 at 10:17
  • @vikeng21 I did not get you what do you mean by "refresh", I checked using "ls target/test-classes" – Neil Sep 30 '14 at 10:19
  • are you running the command in a unix/linux box and facing this issue or in windows. again have you enabled tests to be run – vikeng21 Sep 30 '14 at 10:22
  • @vikeng21 Its a Mac so unix basically . Yes all the files ends with *Test and methods are annotated with @ Test. Runs just fine from Eclipse. – Neil Sep 30 '14 at 10:25
  • Show your full pom file and an example test class and where you have stored the test java file. – khmarbaise Sep 30 '14 at 10:54
  • possible duplicate of [Maven compiler plugin always detecting a set of sources as "stale"](http://stackoverflow.com/questions/17944108/maven-compiler-plugin-always-detecting-a-set-of-sources-as-stale) – maba Sep 30 '14 at 10:56
  • 1
    As you can see in the debug output it says "Stale source detected". It is a known bug: https://jira.codehaus.org/browse/MCOMPILER-209. – maba Sep 30 '14 at 10:58
  • @maba I have tried setting useIncrementalCompilation to false but did not help. – Neil Sep 30 '14 at 11:55

1 Answers1

0

I found the problem finally . The following file had a pattern mentioned which was ignoring the test cases not matching the pattern

src/test/resources/META-INF/services/javax.annotation.processing.Processor

I changed the pattern from

test.MyAnnotation 

to

#test.MyAnnotation 

and it worked ! Any guesses what was the problem and is it for selectively running tests ?

Neil
  • 5,919
  • 15
  • 58
  • 85