custom test phase script issue upgrading Grails from 2.2.2 to 2.4.4

15 views
Skip to first unread message

Claude Daoust

unread,
Mar 2, 2015, 2:32:57 PM3/2/15
to grails-de...@googlegroups.com
Background:

- we use code in the events script to create a custom test phase.
The following is the event code:

eventTestPhasesStart = {phasesToRun ->
println "setting inmem phase"
phasesToRun << "inmem"

def inmemPhaseConfigurer = new IntegrationTestPhaseConfigurer(projectTestRunner.projectTestCompiler, projectLoader)
projectTestRunner.testFeatureDiscovery.configurers.inmem = inmemPhaseConfigurer
def inmemtestTypeName = "inmem"
def inmemtestDirectory = "inmem"
def inmemtestMode = new GrailsTestMode(autowire: true, wrapInTransaction: true, wrapInRequestEnvironment: true)

inmemTestTypes = []
inmemTestTypes << (new GrailsSpecTestType(inmemtestTypeName+"Spock", inmemtestDirectory, inmemtestMode))
inmemTestTypes << (new JUnit4GrailsTestType(inmemtestTypeName+"JUnit", inmemtestDirectory, inmemtestMode))
    projectTestRunner.testFeatureDiscovery.testExecutionContext.inmemTests = inmemTestTypes 
}

This code is included in a plugin we use to support testing.  

The events script is compiled when executing run-app which forced me to add the dependency to the grails test jar.  That solved run-app and I can debug our application as usual.

However, test-app was no longer working.  I had to change the dependency to the test plugin (which contains the events script and other test related stuff) from runtime to compile scope to get test-app and disable forked execution for it to work at all. The custom test phase is created and our inmem test phase scripts are run.

The issue that is still unresolved is that our tests can't run with the debugger as they fail to execute in forked mode which is required for debugging.  The error I get when running test-app in forked mode:
Error running forked test-app: No such property: projectTestRunner for class: _Events

I am guessing that it is unexpected to have test related code in the _events script and that the events script is being executed in the wrong VM.    Where else can this script be placed so it executes with the tests in the correct fork?

Is there another way to create a custom test phase?

thank you
Reply all
Reply to author
Forward
0 new messages