I recently stumbled across the next issue. I was running a Grails 3 integration test in IntelliJ IDEA 15.0.3:
My test was running in the development environment instead of in the test environment!
The problem with running tests from IDEA is that IDEA does not use any Gradle task whatsoever
Solution: Tell IntelliJ to explicitly use the Grails test environment.
It is pretty easy configuration as shown below:
Please note that I added -Dgrails.env=test to my default configuration for JUnit tests. Add it to your default configuration, instead of in a single test configuration. If you do that, the next time you ask IntelliJ to run a test, it will create a new JUnit configuration based on your default configuration. That it is to say: your tests will run in the Grails test environment.
Do you like to read about Groovy/Grails development? Yes, then Subscribe to Groovy Calamari a weekly curated email newsletter about the Groovy ecosystem which I happen to write 😉