apply plugin: 'groovy'
apply plugin: 'jetty'
ext {
webSourceDir = "$buildDir/www"
imageName = "${rootProject.name}-functional-tests"
springVersion = '4.0.7.RELEASE'
}
sourceSets {
funcTest {
groovy {
srcDir file('src/functionalTest/groovy')
}
}
}
eclipse {
classpath {
downloadSources = true
defaultOutputDir = file("$buildDir/classes")
}
project {
name = "${rootProject.name}-functional-tests"
}
}
eclipseJdt.enabled = false
cleanEclipseJdt.enabled = false
jettyRun {
httpPort = System.getenv('PORT') ? System.getenv('PORT') as int : 8080
contextPath = 'status/check'
webAppSourceDirectory = file(webSourceDir)
}
dependencies {
compile project(':app') // include the code that is needed to execute the tests (e.g., any entity classes, etc)
testCompile 'junit:junit:4.11'
testCompile 'cglib:cglib-nodep:3.1'
testCompile 'org.objenesis:objenesis:2.1'
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
testCompile 'org.spockframework:spock-spring:0.7-groovy-2.0'
testCompile "org.springframework:spring-test:${springVersion}"
funcTestCompile sourceSets.main.output
funcTestCompile configurations.testCompile
funcTestRuntime configurations.testRuntime
}
task buildDist(type: Tar, group:'Build', description: 'Builds the Tar distribution of the project.') {
archiveName = "${rootProject.name}-functional-tests.tar"
from('bin') {
into('bin')
}
from(rootProject.projectDir) {
exclude('**/build/**')
exclude('**/*.tar')
exclude('**/.gradle/**')
}
}
task funcTest(type: Test, group:'Verification', description: 'Runs the functional tests.') {
testClassesDir = sourceSets.funcTest.output.classesDir
classpath = sourceSets.funcTest.runtimeClasspath
jvmArgs = ['-Duser.timezone=UTC']
environment = [:] // any necessary env vars for the test
}
task resolveDependencies {
doLast {
project.rootProject.allprojects.each { subProject ->
subProject.buildscript.configurations.each { configuration ->
configuration.resolve()
}
subProject.configurations.each { configuration ->
configuration.resolve()
}
}
}
}
task createWebSourceDir {
doLast {
new File(webSourceDir).mkdirs()
}
}
task collectTestResults(type:Tar, group:'Verification', dependsOn:['createWebSourceDir', 'funcTest'], description: 'Generates a tarball of the collected test report.') {
archiveName = 'functional-test-reports.tar'
destinationDir = file(webSourceDir)
from("$buildDir/reports/tests") {
into('reports/tests')
}
from("$buildDir/test-results") {
into('test-results')
}
}
task execute(dependsOn:['jettyRun'])
/*
* Ensure that the tests are always executed
*/
project.tasks.collectTestResults.outputs.upToDateWhen { false }
project.tasks.funcTest.outputs.upToDateWhen { false }
project.tasks.resolveDependencies.outputs.upToDateWhen { false }
build.finalizedBy(project.tasks.buildDist)
project.tasks.buildDist.dependsOn(['build'])
project.tasks.jettyRun.dependsOn(['collectTestResults'])