Created
February 28, 2013 00:00
-
-
Save behrangsa/5053039 to your computer and use it in GitHub Desktop.
Parallel testing for Grails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
includeTargets << grailsScript("_GrailsInit") | |
def createTestCommand(reportPath, serverPort, chromeDriverPort, testPhaseAndType) { | |
"grails -Dgrails.project.test.reports.dir=${reportPath} -Dserver.port=${serverPort} " + | |
"-Dchrome-driver.port=${chromeDriverPort} test-app ${testPhaseAndType}" | |
} | |
target(main: 'Run lego and functional tests in parallel') { | |
def threads = [] | |
def reportsBaseDir = 'para-reports' | |
def unitTestReportDir = new File(reportsBaseDir, "unit") | |
def functionalTestReportDir = new File(reportsBaseDir, "functional") | |
def legoTestReportDir = new File(reportsBaseDir, "lego") | |
[unitTestReportDir, functionalTestReportDir, legoTestReportDir].each { it.mkdirs() } | |
// unit tests | |
threads << { | |
def command = createTestCommand(unitTestReportDir.absolutePath, 8080, 18080, "unit:unit") | |
println command | |
def builder = new ProcessBuilder(command.split()) | |
builder.redirectErrorStream(true) | |
def process = builder.start() | |
def out = process.inputStream | |
def reader = new BufferedReader(new InputStreamReader(out)) | |
while ((line = reader.readLine()) != null) { | |
println "Unit: " + line | |
} | |
} | |
// functional tests | |
threads << { | |
def command = createTestCommand(functionalTestReportDir.absolutePath, 8181, 18080, "functional:") | |
println command | |
def builder = new ProcessBuilder(command.split()) | |
builder.redirectErrorStream(true) | |
def process = builder.start() | |
def out = process.inputStream | |
def reader = new BufferedReader(new InputStreamReader(out)) | |
while ((line = reader.readLine()) != null) { | |
println "Functional: " + line | |
} | |
} | |
// lego tests | |
threads << { | |
} | |
threads.collect { new Thread(it as Runnable) }.each { it.start() }.each { it.join() } | |
} | |
setDefaultTarget(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment