From d93431d38e18b2b54e9c17bd17c88adc0080c151 Mon Sep 17 00:00:00 2001 From: Dipak Pawar Date: Thu, 4 May 2017 19:18:39 +0530 Subject: [PATCH] * Fixed #177 * Fixed bug of skip test for remote execution --- build/pom.xml | 2 +- .../arquillian/testng/container/TestListener.java | 2 +- .../ShouldProvideVariousTestResultsToTestRunner.java | 6 ++++++ .../testng/container/TestNGTestRunnerTestCase.java | 12 ++++++++++++ .../java/org/jboss/arquillian/testng/Arquillian.java | 3 +++ .../jboss/arquillian/testng/TestNGTestBaseClass.java | 4 ++-- 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/build/pom.xml b/build/pom.xml index 409b9e588..eb4c5d71b 100644 --- a/build/pom.xml +++ b/build/pom.xml @@ -27,7 +27,7 @@ 1 4.12 1.10.19 - 6.9.10 + 6.11 2.5.0 diff --git a/testng/container/src/main/java/org/jboss/arquillian/testng/container/TestListener.java b/testng/container/src/main/java/org/jboss/arquillian/testng/container/TestListener.java index 3ac6a28a4..804f9023a 100644 --- a/testng/container/src/main/java/org/jboss/arquillian/testng/container/TestListener.java +++ b/testng/container/src/main/java/org/jboss/arquillian/testng/container/TestListener.java @@ -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( diff --git a/testng/container/src/test/java/org/jboss/arquillian/testng/container/ShouldProvideVariousTestResultsToTestRunner.java b/testng/container/src/test/java/org/jboss/arquillian/testng/container/ShouldProvideVariousTestResultsToTestRunner.java index c4cde9486..f78173cce 100644 --- a/testng/container/src/test/java/org/jboss/arquillian/testng/container/ShouldProvideVariousTestResultsToTestRunner.java +++ b/testng/container/src/test/java/org/jboss/arquillian/testng/container/ShouldProvideVariousTestResultsToTestRunner.java @@ -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 { @@ -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); diff --git a/testng/container/src/test/java/org/jboss/arquillian/testng/container/TestNGTestRunnerTestCase.java b/testng/container/src/test/java/org/jboss/arquillian/testng/container/TestNGTestRunnerTestCase.java index cbdb1046e..8f5fe9bbc 100644 --- a/testng/container/src/test/java/org/jboss/arquillian/testng/container/TestNGTestRunnerTestCase.java +++ b/testng/container/src/test/java/org/jboss/arquillian/testng/container/TestNGTestRunnerTestCase.java @@ -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 @@ -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(); diff --git a/testng/core/src/main/java/org/jboss/arquillian/testng/Arquillian.java b/testng/core/src/main/java/org/jboss/arquillian/testng/Arquillian.java index aac148317..a3ec79389 100644 --- a/testng/core/src/main/java/org/jboss/arquillian/testng/Arquillian.java +++ b/testng/core/src/main/java/org/jboss/arquillian/testng/Arquillian.java @@ -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.. diff --git a/testng/core/src/test/java/org/jboss/arquillian/testng/TestNGTestBaseClass.java b/testng/core/src/test/java/org/jboss/arquillian/testng/TestNGTestBaseClass.java index ac20e6106..dc1b89948 100644 --- a/testng/core/src/test/java/org/jboss/arquillian/testng/TestNGTestBaseClass.java +++ b/testng/core/src/test/java/org/jboss/arquillian/testng/TestNGTestBaseClass.java @@ -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)); @@ -208,4 +208,4 @@ public Object answer(InvocationOnMock invocation) throws Throwable { return result; } } -} \ No newline at end of file +}