Преглед на файлове

assira.junit - ignore tests

Ranides Atterwim преди 10 години
родител
ревизия
461ea2549c

+ 12 - 3
assira.junit/src/main/java/net/ranides/assira/junit/QTesterSuite.java

@@ -118,20 +118,29 @@ public class QTesterSuite {
         
         public void run(Counter counter, Supplier<?> supplier) throws RuntimeException {
             try {
+                method.invoke(that, supp ? supplier : supplier.get());
                 printf(" - SUITE: %s [%d] %s.%s%n",
                     type.getName(),
                     counter.next(),
                     method.getDeclaringClass().getSimpleName(),
                     method.getName()
                 );
-                method.invoke(that, supp ? supplier : supplier.get());
             } catch (IllegalAccessException | IllegalArgumentException ex) {
                 throw QAssert.rethrow(ex);
             } catch (InvocationTargetException ex) {
-                if(ex.getTargetException() instanceof UnsupportedOperationException) {
+                if(ex.getTargetException() instanceof UnsupportedTestException) {
+                    if( !((UnsupportedTestException)ex.getTargetException()).silent() ) {
+                        printf(" - SUITE: %s [%d] %s.%s - IGNORED%n",
+                            type.getName(),
+                            counter.next(),
+                            method.getDeclaringClass().getSimpleName(),
+                            method.getName()
+                        );
+                    }
+                } else if(ex.getTargetException() instanceof UnsupportedOperationException) {
                     printf(" - SUITE: %s [%d] %s.%s - UNSUPPORTED%n",
                         type.getName(),
-                        counter.value,
+                        counter.next(),
                         method.getDeclaringClass().getSimpleName(),
                         method.getName()
                     );

+ 29 - 0
assira.junit/src/main/java/net/ranides/assira/junit/UnsupportedTestException.java

@@ -0,0 +1,29 @@
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/???
+ */
+package net.ranides.assira.junit;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public class UnsupportedTestException extends UnsupportedOperationException {
+    
+    private final boolean silent;
+    
+    public UnsupportedTestException() {
+        this(false);
+    }
+
+    public UnsupportedTestException(boolean silent) {
+        this.silent = silent;
+    }
+
+    public boolean silent() {
+        return silent;
+    }
+    
+}

+ 3 - 3
assira.junit/src/test/java/net/ranides/assira/junit/QTesterSuiteTest.java

@@ -55,9 +55,9 @@ public class QTesterSuiteTest {
     );
     
     private static final String EXPECTED_OUT = String.format(
-        " - SUITE: net.ranides.assira.junit.mockup.TesterInterfaces$IntA [1] ForSupport.run%n"+
-        " - SUITE: net.ranides.assira.junit.mockup.TesterInterfaces$IntA [2] ForSupport.unsupported%n"+
-        " - SUITE: net.ranides.assira.junit.mockup.TesterInterfaces$IntA [2] ForSupport.unsupported - UNSUPPORTED%n"
+        " - SUITE: net.ranides.assira.junit.mockup.TesterInterfaces$IntA [1] ForSupport.ignored - IGNORED%n" +
+        " - SUITE: net.ranides.assira.junit.mockup.TesterInterfaces$IntA [2] ForSupport.run%n"+
+        " - SUITE: net.ranides.assira.junit.mockup.TesterInterfaces$IntA [3] ForSupport.unsupported - UNSUPPORTED%n"
     );
     
     private static final List<String> EXPECTED_RES = Arrays.asList(

+ 11 - 0
assira.junit/src/test/java/net/ranides/assira/junit/mockup/Testers.java

@@ -9,6 +9,7 @@ package net.ranides.assira.junit.mockup;
 import java.util.Map;
 import java.util.function.Supplier;
 import javax.annotation.Resource;
+import net.ranides.assira.junit.UnsupportedTestException;
 import net.ranides.assira.junit.mockup.TesterObjects.*;
 import net.ranides.assira.junit.mockup.TesterInterfaces.*;
 import org.junit.Ignore;
@@ -52,6 +53,16 @@ public class Testers {
         public void unsupported(IntA object) {
             throw new UnsupportedOperationException("NSE");
         }
+        
+        @Test
+        public void ignored(IntA object) {
+            throw new UnsupportedTestException();
+        }
+        
+        @Test
+        public void silent(IntA object) {
+            throw new UnsupportedTestException(true);
+        }
 
     }