[GRADLE-847] TestNG tests fails if they throw exceptions (even expected) Created: 09/Mar/10  Updated: 04/Jan/13  Resolved: 24/Nov/10

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 0.9-rc-1

Type: Bug
Reporter: Tomek Kaczanowski Assignee: Adam Murdoch
Resolution: Fixed Votes: 0

Attachments: Zip Archive testng.zip    


Execution of such this test will FAIL:
package org.gradle.sample.testing;

import org.testng.annotations.Test;
import static org.testng.Assert.assertTrue;

public class SimpleTest {
public void testThatPasses()

{ assertTrue(true); }

@Test(expectedExceptions = IllegalStateException.class)
public void testThatThrowsExceptionAndPasses()

{ throw new IllegalStateException("whatever"); }


gradle clean test
:processResources UP-TO-DATE
:testTest org.gradle.sample.testing.SimpleTest FAILED
1 out of 2 tests failed.

FAILURE: Build failed with an exception.

  • Where:
    Build file '/home/tomek/Documents/gradle/cookbook/testng/build.gradle'
  • What went wrong:
    Execution failed for task ':test'.
    Cause: There were failing tests. See the report at /home/tomek/Documents/gradle/cookbook/testng/build/reports/tests.
  • Try:
    Run with -s or -d option to get more details. Run with -S option to get the full (very verbose) stacktrace.


Total time: 12.168 secs

The html report will show all green (and rightly so).

It is broken in gradle-0.9-20100309130436+0300-bin but worked fine gradle-0.9-20100302224259+0100 (or some previous version, not sure about that).

See attached project.

Generated at Wed Jun 30 11:40:28 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.