db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1539729 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit: BaseTestCase.java TestConfiguration.java
Date Thu, 07 Nov 2013 17:34:09 GMT
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;
 
     /**



Mime
View raw message