I am using gradle 1.2 and testng 6.7. I noticed when my test case fails, the file ‘build/reports/tests/index.html’ was not generated even though gradle kept referring me to that file for error details.
Also, after that, when I ran “gradle test”, it kept failing even though I had corrected the test code so the test should pass. I had tried “gradle clean” to wipe out everthing (and manually remove the build dir) but to no avail.
I am attaching my small build.gradle and simple test case:
// build.gradle buildscript {
repositories {
add(new org.apache.ivy.plugins.resolver.URLResolver()) {
name = ‘GitHub’
addArtifactPattern ‘http://cloud.github.com/downloads/[organisation]/[module]/[module]-[revision].[ext]’
}
}
dependencies {
classpath ‘bmuschko:gradle-tomcat-plugin:0.9.5’
} }
apply plugin: ‘java’ apply plugin: ‘groovy’ apply plugin: ‘war’ apply plugin: ‘tomcat’
repositories {
mavenCentral() }
dependencies {
// these two groups are for sample greeting only, may not be needed
compile group: ‘commons-io’, name: ‘commons-io’, version: ‘1.4’
compile group: ‘log4j’, name: ‘log4j’, version: ‘1.2.15’, ext: ‘jar’
compile ‘org.apache.camel:camel-core:2.10.1’
compile ‘com.amazonaws:aws-java-sdk:1.3.20’
testCompile ‘org.testng:testng:6.7’
// for tomcat plugin
def tomcatVersion = ‘7.0.30’
tomcat “org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}”,
“org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}”
tomcat(“org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}”) {
exclude group: ‘org.eclipse.jdt.core.compiler’, module: ‘ecj’
} }
test {
useTestNG() {
/*
suiteXmlBuilder().suite(name: ‘test-suite’) {
test (name : ‘testing-testng’, annotations : ‘JDK’, verbose:‘1’) {
classes([:]) {
‘class’ (name: ‘*’) {
}
}
}
}
*/
}
testLogging.showStandardStreams = true
options {
listeners << ‘org.uncommons.reportng.HTMLReporter’
listeners << ‘org.uncommons.reportng.JUnitXMLReporter’
} }
// small testng test package com.stellatechnology.prototype;
import org.testng.Reporter; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static org.testng.Assert.*;
/**
-
User: jma
-
Date: 10/3/12
-
Time: 2:25 PM
*/ public class FirstTest {
private static final String testString = “hello”;
@BeforeClass
public void setUp() throws Exception {
//Reporter.log(“Before test”);
}
@Test
public void testMethod() {
//throw new RuntimeException(“test123”);
assertEquals(“hello”, testString);
}
@AfterClass
public void tearDown() throws Exception {
//Reporter.log(“After test”);
} }