You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2013/11/07 18:34:09 UTC

svn commit: r1539729 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit: BaseTestCase.java TestConfiguration.java

Author: kmarsden
Date: Thu Nov  7 17:34:08 2013
New Revision: 1539729

URL: http://svn.apache.org/r1539729
Log:
DERBY-6401 Create a test option to stop running Junit tests after first failure or error
Adds test option. If run with  -Dderby.tests.stopAfterFirstFail=true tests will stop after first failure or error


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=1539729&r1=1539728&r2=1539729&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java Thu Nov  7 17:34:08 2013
@@ -92,6 +92,7 @@ public abstract class BaseTestCase
     public void runBare() throws Throwable {
         TestConfiguration config = getTestConfiguration();
         boolean trace = config.doTrace();
+        boolean stopAfterFirstFail = config.stopAfterFirstFail();
         long startTime = 0;
         if ( trace )
         {
@@ -155,7 +156,15 @@ public abstract class BaseTestCase
                 if (stackOut != null) {
                     stackOut.close();
                 }
-                throw running;
+                if (stopAfterFirstFail) {
+                    // if run with -Dderby.tests.stopAfterFirstFail=true
+                    // exit after reporting failure. Useful for debugging
+                    // cascading failures or errors that lead to hang.
+                    running.printStackTrace(out);
+                    System.exit(1);
+                }
+                else
+                    throw running;
             }
         }
         finally{

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java?rev=1539729&r1=1539728&r2=1539729&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java Thu Nov  7 17:34:08 2013
@@ -119,6 +119,13 @@ public final class TestConfiguration {
     private final static String KEY_VERBOSE = "derby.tests.debug";    
     private final static String KEY_LOGIN_TIMEOUT = "derby.tests.login.timeout";    
     private final static String KEY_TRACE = "derby.tests.trace";
+
+    /**
+     * derby.tests.stopAfterFirstFail - debugging property to exit after 
+     * first failure. Can be useful for debugging cascading failures or errors
+     * that lead to hang scenario.
+     */
+    private final static String KEY_STOP_AFTER_FIRST_FAIL = "derby.tests.stopAfterFirstFail";
     private final static String KEY_SSL = "ssl";
     private final static String KEY_JMX_PORT = "jmxPort";
     
@@ -1128,7 +1135,9 @@ public final class TestConfiguration {
         this.doTrace = Boolean.valueOf(
             getSystemProperties().getProperty(KEY_TRACE)).
             booleanValue();
-        
+        this.stopAfterFirstFail = Boolean.valueOf(
+                getSystemProperties().getProperty(KEY_STOP_AFTER_FIRST_FAIL)).
+                booleanValue();
         this.jdbcClient = JDBCClient.getDefaultEmbedded();
         this.ssl = null;
         this.jmxPort = getNextAvailablePort();
@@ -1945,6 +1954,9 @@ public final class TestConfiguration {
         return doTrace;
     }
 
+    public boolean stopAfterFirstFail() {
+        return stopAfterFirstFail;
+    }
 	/**
 	 * <p>
 	 * Return true if we classes are being loaded from jar files. For the time
@@ -2053,6 +2065,7 @@ public final class TestConfiguration {
     private final int jmxPort;
     private boolean isVerbose;
     private boolean doTrace;
+    private boolean stopAfterFirstFail;
     private String ssl;
 
     /**