Dead simple build.gradle:
apply plugin: 'java'
apply plugin: 'idea'
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.11'
testCompile 'org.testng:testng:6.1.1'
}
Dead simple test:
import org.testng.Assert;
import org.testng.annotations.Test;
public class MainTest {
@Test
public void testMain() {
Assert.fail("fail");
}
}
run gradle test via command line or through intellij. result:
"C:\Program Files\Java\jdk1.7.0_05\bin\java" -Dgradle.home=C:\Users\spont200\gradle-1.5 "-Dtools.jar=C:\Program Files\Java\jdk1.7.0_05\lib\tools.jar" -Didea.launcher.port=7533 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\spont200\gradle-1.5\lib\groovy-all-1.8.6.jar;C:\Users\spont200\gradle-1.5\lib\gradle-base-services-1.5.jar;C:\Users\spont200\gradle-1.5\lib\gradle-base-services-groovy-1.5.jar;C:\Users\spont200\gradle-1.5\lib\gradle-cli-1.5.jar;C:\Users\spont200\gradle-1.5\lib\gradle-core-1.5.jar;C:\Users\spont200\gradle-1.5\lib\gradle-launcher-1.5.jar;C:\Users\spont200\gradle-1.5\lib\gradle-messaging-1.5.jar;C:\Users\spont200\gradle-1.5\lib\gradle-native-1.5.jar;C:\Users\spont200\gradle-1.5\lib\gradle-open-api-1.5.jar;C:\Users\spont200\gradle-1.5\lib\gradle-tooling-api-1.5.jar;C:\Users\spont200\gradle-1.5\lib\gradle-ui-1.5.jar;C:\Users\spont200\gradle-1.5\lib\gradle-wrapper-1.5.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.gradle.launcher.GradleMain --build-file C:\workspace\disnetty\dispeptic\build.gradle test
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
BUILD SUCCESSFUL
Total time: 5.015 secs
But if I switch ONLY the imports to junit, like so:
import org.junit.Assert;
import org.junit.Test;
public class MainTest {
@Test
public void testMain() {
Assert.fail("fail");
}
}
and run gradle test, I get the appropriate error:
com.seanpont.disnetty.MainTest > testMain FAILED
java.lang.AssertionError at MainTest.java:10
1 test completed, 1 failed
:test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///C:/workspace/disnetty/dispeptic/build/reports/tests/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED