Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARQ-2086 Test failures not reported with recent versions of TestNG #134

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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.11</version.testng>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be changed to 6.12. @dipak-pawar can you give me push rights to your repo or to this branch?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<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;
}
}
}
}