Reputation: 374
After upgrading from grails 2.2.4 to grails 2.3.1 when running the "test-app" target from inside IntelliJ IDEA I get multiple "unable to resolve class" errors when compiling the unit tests :
| Error Compilation error compiling [unit] tests: startup failed:
/mnt/hgfs/Projekte/javandry/minigolf-webapp/test/unit/de/javandry/minigolf/webapp/controller/BallControllerTests.groovy: 3: unable to resolve class de.javandry.minigolf.webapp.Ball
@ line 3, column 1.
import de.javandry.minigolf.webapp.Ball
^
It looks like all classes from the application itself are not visible from within the unit tests. When I run the target from the command line everything's fine.
I already tried to:
$USER_HOME/.grails/2.3.1/projects
directorygrails.project.work.dir = "target"
in the BuildConfig.groovy
$PROJECT_HOME/target
directoryThe errors still appear.
Now, I run out of ideas what else I could try.
Any ideas out there?
Upvotes: 1
Views: 2530
Reputation: 374
After trying again and again I finally got my unit tests compiled.
In my run configurations I called the "test-app" target using the -clean
option to force a clean build. According to the log output and the target directory grails cleans the target directory but does not compile the main classes afterwards. So, the target directory does not contain the classes sub directory which leads to the errors when compiling the unit tests.
Removing the -clean
option from my run configuration the grails build compiles the main classes and afterwards successfully the unit tests. I didn't used this option on the command line before, so everythings worked fine there leading me to seek for an error in IntelliJ.
I did some tests with a fresh test project on the command line. grails test-app
successfully builds the project where grails test-app -clean
fails. I found GRAILS-10642 describing a similar behaviour which should be fixed in grails 2.3.2.
Upvotes: 2