Skip to content

Instantly share code, notes, and snippets.

@hgontijo
Created June 23, 2015 14:24
Show Gist options
  • Select an option

  • Save hgontijo/3eea875fe42748b01266 to your computer and use it in GitHub Desktop.

Select an option

Save hgontijo/3eea875fe42748b01266 to your computer and use it in GitHub Desktop.
gradle script to execute tests by consuming an external jar.
apply plugin: 'java'
project.ext.set('testIncludeDefault', 'com/vmware/ui/login/**')
repositories {
mavenCentral()
}
dependencies {
runtime fileTree(dir: 'libs', include: ['*.jar'])
}
configurations {
provided
testRuntime.extendsFrom(provided)
}
task expandDependencies << {
def includes = System.getProperty('testInclude', project.testIncludeDefault)
FileTree tree = fileTree(dir: 'libs', include: '*.jar')
tree.visit { element ->
println "Unpacking $element.relativePath => $element.file"
ant.unzip(src: element.file, dest: "$buildDir/classes/test") {
patternset() {
include(name: includes)
exclude(name: 'META-INF/**')
exclude(name: 'LICENSE')
exclude(name: 'NOTICE')
}
}
}
}
test {
dependsOn expandDependencies
useTestNG() { }
// Pass along current system properties since test are executed in a forked JVM
systemProperties System.properties
logger.debug "systemProperties: ${systemProperties}"
include System.getProperty('testInclude', project.testIncludeDefault)
// maxParallelForks=5
onOutput { descriptor, event ->
logger.lifecycle(event.message )
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment