[testng] 85/355: Add tests for #566

Eugene Zhukov eugene-guest at moszumanska.debian.org
Tue Aug 18 10:19:50 UTC 2015


This is an automated email from the git hooks/post-receive script.

eugene-guest pushed a commit to annotated tag OpenBSD
in repository testng.

commit 3fc7bda3b184c10d61910862a55504aa639cc83c
Author: Vladislav Rassokhin <vladrassokhin at gmail.com>
Date:   Sun Nov 23 00:16:09 2014 +0300

    Add tests for #566
---
 .../test/InvocationAndSuccessPercentageTest.java   |  4 ++--
 .../test/dataprovider/DataProviderWithError.java   | 25 ++++++++++++++++++++++
 .../test/dataprovider/FailingDataProviderTest.java | 15 ++++++++-----
 3 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/src/test/java/test/InvocationAndSuccessPercentageTest.java b/src/test/java/test/InvocationAndSuccessPercentageTest.java
index ec0254f..56f4434 100644
--- a/src/test/java/test/InvocationAndSuccessPercentageTest.java
+++ b/src/test/java/test/InvocationAndSuccessPercentageTest.java
@@ -67,9 +67,9 @@ public class InvocationAndSuccessPercentageTest extends BaseTest {
     * 1 failed but within success percentage
     * 1 failed
     */
-   @Test(enabled = false)
+   @Test
    public void successPercentageThatFails() {
-     addClass("test.sample.InvocationCountTest");
+     addClass(test.sample.InvocationCountTest.class);
      addIncludedGroup("successPercentageThatFailsOnly");
      run();
      String[] passed = {
diff --git a/src/test/java/test/dataprovider/DataProviderWithError.java b/src/test/java/test/dataprovider/DataProviderWithError.java
new file mode 100644
index 0000000..a7b8c7f
--- /dev/null
+++ b/src/test/java/test/dataprovider/DataProviderWithError.java
@@ -0,0 +1,25 @@
+package test.dataprovider;
+
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * @author Vladislav.Rassokhin
+ */
+public class DataProviderWithError {
+  @Test(dataProvider = "Data", invocationCount = 2)
+  public void testShouldSkip() throws Exception {
+    Assert.fail();
+  }
+
+  @Test(dataProvider = "Data", invocationCount = 2, successPercentage = 10)
+  public void testShouldSkipEvenIfSuccessPercentage() throws Exception {
+    Assert.fail();
+  }
+
+  @DataProvider(name = "Data")
+  public static Object[][] Data() {
+    throw new RuntimeException("Fail");
+  }
+}
diff --git a/src/test/java/test/dataprovider/FailingDataProviderTest.java b/src/test/java/test/dataprovider/FailingDataProviderTest.java
index fff2564..ee31493 100644
--- a/src/test/java/test/dataprovider/FailingDataProviderTest.java
+++ b/src/test/java/test/dataprovider/FailingDataProviderTest.java
@@ -3,27 +3,32 @@ package test.dataprovider;
 import org.testng.Assert;
 import org.testng.TestListenerAdapter;
 import org.testng.TestNG;
-import org.testng.TestNGException;
 import org.testng.annotations.Test;
 
 import test.SimpleBaseTest;
 
 public class FailingDataProviderTest extends SimpleBaseTest {
-  private void shouldSkipOne(Class cls, String message) {
+  private void shouldSkip(Class cls, String message, int expected) {
     TestNG testng = create(cls);
     TestListenerAdapter tla = new TestListenerAdapter();
     testng.addListener(tla);
     testng.run();
-    Assert.assertEquals(tla.getSkippedTests().size(), 1, message);
+    Assert.assertEquals(tla.getSkippedTests().size(), expected, message);
   }
 
   @Test(description = "TESTNG-142: Exceptions in DataProvider are not reported as failed test")
   public void failingDataProvider() {
-    shouldSkipOne(FailingDataProvider.class, "Test method should be marked as skipped");
+    shouldSkip(FailingDataProvider.class, "Test method should be marked as skipped", 1);
   }
 
   @Test(description = "TESTNG-447: Abort when two data providers have the same name")
   public void duplicateDataProviders() {
-    shouldSkipOne(DuplicateDataProviderSampleTest.class, "");
+    shouldSkip(DuplicateDataProviderSampleTest.class, "", 1);
+  }
+
+  @Test
+  public void failingDataProviderAndInvocationCount() throws Exception {
+    shouldSkip(DataProviderWithError.class,
+        "Test should be skipped even if invocation counter and success percentage set", 4);
   }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/testng.git



More information about the pkg-java-commits mailing list