assertj-assertions-generator-maven-plugin icon indicating copy to clipboard operation
assertj-assertions-generator-maven-plugin copied to clipboard

Plugin randomly generates classes that don't compile

Open mpiela opened this issue 6 years ago • 1 comments

In some specific case the assertions generated by the plugin do not compile. This seems to happen randomly - I've prepared a simple example module (assertj-generator-bug.zip) that on my machine fails about 50% of the time.

$ unzip assertj-generator-bug.zip
$ cd assertj-generator-bug
$ mvn clean install

[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< com.exampl:assertj-generator-bug >------------------
[INFO] Building assertj-generator-bug 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ assertj-generator-bug ---
[INFO] Deleting /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ assertj-generator-bug ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ assertj-generator-bug ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 2 source files to /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/classes
[INFO] 
[INFO] --- assertj-assertions-generator-maven-plugin:2.2.0:generate-assertions (default) @ assertj-generator-bug ---
[INFO] JUnit not found in project classpath => JUnitSoftAssertions entry point class won't be generated.
[INFO] 

====================================
AssertJ assertions generation report
====================================

--- Generator input parameters ---

Generating AssertJ assertions for classes:
- com.example.SomeService

--- Generator results ---

Directory where custom assertions files have been generated:
- /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions

Custom assertions files generated:
- /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/SomeServiceAssert.java

Assertions entry point class has been generated in file:
- /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/Assertions.java

SoftAssertions entry point class has been generated in file:
- /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/SoftAssertions.java

[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ assertj-generator-bug ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/USERS/mpiela/devel/tmp/assertj-generator-bug/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ assertj-generator-bug ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 3 source files to /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/SomeServiceAssert.java:[37,38] cannot find symbol
  symbol:   class E
  location: class com.example.SomeServiceAssert
[ERROR] /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/SomeServiceAssert.java:[57,69] cannot find symbol
  symbol:   class E
  location: class com.example.SomeServiceAssert
[ERROR] /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/SomeServiceAssert.java:[80,42] cannot find symbol
  symbol:   class E
  location: class com.example.SomeServiceAssert
[ERROR] /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/SomeServiceAssert.java:[100,73] cannot find symbol
  symbol:   class E
  location: class com.example.SomeServiceAssert
[ERROR] /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/SomeServiceAssert.java:[124,46] cannot find symbol
  symbol:   class E
  location: class com.example.SomeServiceAssert
[ERROR] /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/SomeServiceAssert.java:[145,77] cannot find symbol
  symbol:   class E
  location: class com.example.SomeServiceAssert
[INFO] 6 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.157 s
[INFO] Finished at: 2019-06-17T11:55:59+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:testCompile (default-testCompile) on project assertj-generator-bug: Compilation failure: Compilation failure: 
[ERROR] /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/SomeServiceAssert.java:[37,38] cannot find symbol
[ERROR]   symbol:   class E
[ERROR]   location: class com.example.SomeServiceAssert
[ERROR] /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/SomeServiceAssert.java:[57,69] cannot find symbol
[ERROR]   symbol:   class E
[ERROR]   location: class com.example.SomeServiceAssert
[ERROR] /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/SomeServiceAssert.java:[80,42] cannot find symbol
[ERROR]   symbol:   class E
[ERROR]   location: class com.example.SomeServiceAssert
[ERROR] /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/SomeServiceAssert.java:[100,73] cannot find symbol
[ERROR]   symbol:   class E
[ERROR]   location: class com.example.SomeServiceAssert
[ERROR] /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/SomeServiceAssert.java:[124,46] cannot find symbol
[ERROR]   symbol:   class E
[ERROR]   location: class com.example.SomeServiceAssert
[ERROR] /home/USERS/mpiela/devel/tmp/assertj-generator-bug/target/generated-test-sources/assertj-assertions/com/example/SomeServiceAssert.java:[145,77] cannot find symbol
[ERROR]   symbol:   class E
[ERROR]   location: class com.example.SomeServiceAssert
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

mpiela avatar Jun 17 '19 09:06 mpiela

Sorry about that, I unfortunately don't have the time to maintain this project :( But I'm happy to take PR for fixing bugs (if it is not too much work)

joel-costigliola avatar Jun 17 '19 21:06 joel-costigliola