Home Grails 3: IllegalStateException after running integration test
Reply: 2

Grails 3: IllegalStateException after running integration test

Erando Published in 2018-01-04 15:24:49Z

I keep getting an exception when I run my integration test:

import grails.testing.mixin.integration.Integration
import grails.transaction.Rollback
import org.springframework.beans.factory.annotation.Autowired
import spock.lang.Specification

class EmailSpec extends Specification {

    EmailService service

//    def setup() {
//    }
//    def cleanup() {
//    }

    def 'test send email'() {
        when: 'email gets sent'
        def sendMailCalled = false
        service.metaClass.sendTestEMail = {
            sendMailCalled = true

        sendMailCalled == true


"C:\Program Files\Java\jdk1.8.0_112\bin\java" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.4\lib\idea_rt.jar=49498:C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.4\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\user\AppData\Local\Temp\classpath.jar com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 "de.mypackeage.EmailSpec,test send email"

java.lang.IllegalStateException: No GORM implementations configured. Ensure GORM has been initialized correctly

    at org.grails.datastore.gorm.GormEnhancer.findSingleDatastore(GormEnhancer.groovy:380)
    at org.grails.datastore.gorm.GormEnhancer.findSingleTransactionManager(GormEnhancer.groovy:399)
    at de.mypackeage.EmailSpec.test send email(EmailSpec.groovy)

Process finished with exit code -1

The test already ran without problems but I don't really know why it would'nt run anymore. Any kind of help is appreciated.

The project is set up with Grails 3.3.1

Erando Reply to 2018-01-05 10:23:47Z

The problem was that I executed the test in IntelliJ as an JUnit test. So the grails context didn't start up and resulted in that error.

Kurt Bliefernich
Kurt Bliefernich Reply to 2018-01-11 02:40:11Z

I run integration tests from IntelliJ frequently.

If you edit the configurations (Upper Right) -> Defaults -> JUnit Set the VM options to -Dgrails.env=test -ea

That will enable the "test" profile to be executed in intellij.

Hope it helps.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.31761 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO