@@ -40,6 +40,7 @@ import org.codehaus.groovy.grails.test.event.GrailsTestEventConsoleReporter
4040
4141includeTargets << grailsScript(" _GrailsBootstrap" )
4242includeTargets << grailsScript(" _GrailsRun" )
43+ includeTargets << grailsScript(" _GrailsWar" )
4344includeTargets << grailsScript(" _GrailsSettings" )
4445includeTargets << grailsScript(" _GrailsClean" )
4546
@@ -130,11 +131,11 @@ target(allTests: "Runs the project's tests.") {
130131 convertedPhases[phaseName] = types. collect { rawType ->
131132 if (rawType instanceof CharSequence ) {
132133 def rawTypeString = rawType. toString()
133- if (phaseName in [ ' integration' , ' functional ' ] ) {
134+ if (phaseName == ' integration' ) {
134135 def mode = new JUnit3GrailsTestTypeMode (
135136 autowire : true ,
136- wrapInTransaction : phaseName == " integration " ,
137- wrapInRequestEnvironment : phaseName == " integration "
137+ wrapInTransaction : true ,
138+ wrapInRequestEnvironment : true
138139 )
139140 new JUnit3GrailsTestType (rawTypeString, rawTypeString, mode)
140141 } else {
@@ -334,25 +335,51 @@ integrationTestPhaseCleanUp = {
334335 * Starts up the test server.
335336 */
336337functionalTestPhasePreparation = {
337- packageApp()
338- testOptions. https ? runAppHttps() : runApp()
338+ runningFunctionalTestsInline = ! testOptions. containsKey(' baseUrl' ) || testOptions. inline
339+ runningFunctionalTestsAgainstWar = testOptions. war
340+
341+ if (runningFunctionalTestsAgainstWar) {
342+ // need to swap out the args map so any test phase/targetting patterns
343+ // aren't intepreted as the war name.
344+ def realArgsMap = argsMap
345+ argsMap = [:]
346+ war()
347+ argsMap = realArgsMap
348+
349+ testOptions. https ? runWarHttps() : runWar()
350+ } else if (runningFunctionalTestsInline) {
351+ packageApp()
352+ testOptions. https ? runAppHttps() : runApp()
353+ prevAppCtx = binding. hasProperty(' appCtx' ) ? appCtx : null
354+ appCtx = ApplicationHolder . application. mainContext
355+ initPersistenceContext()
356+ }
339357
340- prevAppCtx = binding. hasProperty(' appCtx' ) ? appCtx : null
341- appCtx = ApplicationHolder . application. mainContext
358+ if (testOptions. containsKey(' baseUrl' )) {
359+ functionalBaseUrl = testOptions. baseUrl
360+ } else {
361+ functionalBaseUrl = (testOptions. httpsBaseUrl ? ' https' : ' http' ) + " ://localhost:$serverPort $serverContextPath /"
362+ }
342363
343- initPersistenceContext( )
364+ System . setProperty(grailsSettings . FUNCTIONAL_BASE_URL_PROPERTY , functionalBaseUrl )
344365}
345366
346367/**
347368 * Shuts down the test server.
348369 */
349370functionalTestPhaseCleanUp = {
350- destroyPersistenceContext()
351-
352- appCtx?. close()
353- appCtx = prevAppCtx
371+ if (runningFunctionalTestsInline) {
372+ destroyPersistenceContext()
373+ appCtx?. close()
374+ appCtx = prevAppCtx
375+ }
376+
377+ if (runningFunctionalTestsInline || runningFunctionalTestsAgainstWar) {
378+ stopServer()
379+ }
354380
355- stopServer()
381+ functionalBaseUrl = null
382+ System . setProperty(grailsSettings. FUNCTIONAL_BASE_URL_PROPERTY , ' ' )
356383}
357384
358385otherTestPhasePreparation = {}
0 commit comments