Skip to content

Instantly share code, notes, and snippets.

@patrickcousins
Created May 8, 2015 18:50
Show Gist options
  • Save patrickcousins/c745dd41595219954262 to your computer and use it in GitHub Desktop.
Save patrickcousins/c745dd41595219954262 to your computer and use it in GitHub Desktop.
robolectric {
// Configure includes / excludes
include '**/*Test.class'
exclude '**/espresso/**/*.class'
// Configure max heap size of the test JVM
//maxHeapSize = '2048m'
// Configure the test JVM arguments - Does not apply to Java 8
//jvmArgs '-XX:MaxPermSize=512m', '-XX:-UseSplitVerifier'
// Specify max number of processes (default is 1)
//maxParallelForks = 4
// Specify max number of test classes to execute in a test process
// before restarting the process (default is unlimited)
//forkEvery = 150
// configure whether failing tests should fail the build
ignoreFailures true
// use afterTest to listen to the test execution results
afterTest { descriptor, result ->
System.setProperty('org.gradle.color.success', 'GREEN')
def out = services.get(StyledTextOutputFactory).create("blah")
def resultStyle = getResultStyle(String.valueOf(result.resultType))
out.style(Style.Info)
out.append("Executing test for ")
out.withStyle(Style.Normal).format("%s", "${descriptor.name}")
out.withStyle(resultStyle).format(" %s", "${result.resultType}")
out.println()
}
}
def getResultStyle(String result) {
def style = Style.Normal
switch (result) {
case "SUCCESS":
style = Style.Success
break
case "FAILED":
style = Style.Failure
break
}
return style
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment