Skip to content

Commit

Permalink
fix(ARQ-2086): test failures not reported with recent versions of TestNG
Browse files Browse the repository at this point in the history
  • Loading branch information
dipak-pawar authored and bartoszmajsak committed Nov 27, 2017
1 parent ac59fd1 commit 5eddd66
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<version.javax.inject>1</version.javax.inject>
<version.junit>4.12</version.junit>
<version.mockito_all>1.10.19</version.mockito_all>
<version.testng>6.9.10</version.testng>
<version.testng>6.13</version.testng>
<version.assertj>2.5.0</version.assertj>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public TestResult getTestResult() {
return TestResult.failed(
context.getFailedTests().getAllResults().iterator().next().getThrowable());
} else if (context.getSkippedTests().size() > 0) {
return TestResult.skipped();
return TestResult.skipped().setThrowable(context.getSkippedTests().getAllResults().iterator().next().getThrowable());
}
if (context.getPassedTests().size() > 0) {
return TestResult.passed().setThrowable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.lang.reflect.Method;
import org.testng.Assert;
import org.testng.SkipException;
import org.testng.annotations.DataProvider;

public class ShouldProvideVariousTestResultsToTestRunner {
Expand All @@ -42,6 +43,11 @@ public void shouldProvideFailingTestToRunner() throws Exception {
Assert.fail("Failing by design");
}

@org.testng.annotations.Test
public void shouldProvideSkippingTestToRunner() throws Exception {
throw new SkipException("Skipping test", new Throwable("Skip exception"));
}

@org.testng.annotations.Test(dataProvider = "xx")
public void shouldBeAbleToUseOtherDataProviders(Method m) throws Exception {
Assert.assertNotNull(m);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.jboss.arquillian.testng.Arquillian;
import org.junit.Assert;
import org.junit.Test;
import org.testng.SkipException;

public class TestNGTestRunnerTestCase extends Arquillian {
@Test
Expand All @@ -44,6 +45,17 @@ public void shouldReturnFailedTest() throws Exception {
Assert.assertEquals(AssertionError.class, result.getThrowable().getClass());
}

@Test
public void shouldReturnSkippedTest() throws Exception {
TestNGTestRunner runner = new TestNGTestRunner();
TestResult result =
runner.execute(ShouldProvideVariousTestResultsToTestRunner.class, "shouldProvideSkippingTestToRunner");

Assert.assertNotNull(result);
Assert.assertEquals(TestResult.Status.SKIPPED, result.getStatus());
Assert.assertEquals(SkipException.class, result.getThrowable().getClass());
}

@Test
public void shouldReturnFailedTestAfterConfigurationError() throws Exception {
TestNGTestRunner runner = new TestNGTestRunner();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ public Object getInstance() {
}
}
testResult.setThrowable(result.getThrowable());

// setting status as failed.
testResult.setStatus(2);
}

// calculate test end time. this is overwritten in the testng invoker..
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private XmlSuite createSuite(String[] groups, Class<?>... classes) {
XmlSuite suite = new XmlSuite();
suite.setName("Arquillian - TEST");

suite.setConfigFailurePolicy("continue");
suite.setConfigFailurePolicy(XmlSuite.FailurePolicy.CONTINUE);
XmlTest test = new XmlTest(suite);
if (groups != null) {
test.setIncludedGroups(Arrays.asList(groups));
Expand Down Expand Up @@ -208,4 +208,4 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
return result;
}
}
}
}

0 comments on commit 5eddd66

Please sign in to comment.