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 ka...@apache.org on 2007/06/30 00:01:07 UTC
svn commit: r552046 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit:
BaseTestCase.java TestConfiguration.java
Author: kahatlen
Date: Fri Jun 29 15:01:06 2007
New Revision: 552046
URL: http://svn.apache.org/viewvc?view=rev&rev=552046
Log:
DERBY-2667: Create more robust junit TestRunner for running derby tests
Added property derby.tests.trace which enables printing of test name
and time spent.
Contributed by Ole Solberg.
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?view=diff&rev=552046&r1=552045&r2=552046
==============================================================================
--- 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 Fri Jun 29 15:01:06 2007
@@ -74,6 +74,12 @@
* setUp, tearDown methods and decorators.
*/
public void runBare() throws Throwable {
+ boolean trace = TestConfiguration.getCurrent().doTrace();
+ long startTime = 0;
+ if ( trace )
+ {
+ startTime = System.currentTimeMillis();
+ }
// install a default security manager if one has not already been
// installed
@@ -85,7 +91,17 @@
}
}
- super.runBare();
+ try {
+ super.runBare();
+ }
+ finally{
+ if ( trace )
+ {
+ long timeUsed = System.currentTimeMillis() - startTime;
+ out.println();
+ out.print(getName() + " used " + timeUsed + " ms ");
+ }
+ }
}
/**
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?view=diff&rev=552046&r1=552045&r2=552046
==============================================================================
--- 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 Fri Jun 29 15:01:06 2007
@@ -83,6 +83,7 @@
private final static String KEY_HOSTNAME = "hostName";
private final static String KEY_PORT = "port";
private final static String KEY_VERBOSE = "derby.tests.debug";
+ private final static String KEY_TRACE = "derby.tests.trace";
private final static String KEY_SSL = "ssl";
/**
@@ -645,6 +646,9 @@
this.isVerbose = Boolean.valueOf(
getSystemProperties().getProperty(KEY_VERBOSE)).
booleanValue();
+ this.doTrace = Boolean.valueOf(
+ getSystemProperties().getProperty(KEY_TRACE)).
+ booleanValue();
this.jdbcClient = JDBCClient.getDefaultEmbedded();
this.ssl = null;
@@ -665,6 +669,7 @@
this.userPassword = copy.userPassword;
this.isVerbose = copy.isVerbose;
+ this.doTrace = copy.doTrace;
this.port = copy.port;
this.jdbcClient = copy.jdbcClient;
@@ -686,6 +691,7 @@
this.userPassword = copy.userPassword;
this.isVerbose = copy.isVerbose;
+ this.doTrace = copy.doTrace;
this.port = port;
this.jdbcClient = client;
@@ -716,6 +722,7 @@
copy.passwordToken : passwordToken;
this.isVerbose = copy.isVerbose;
+ this.doTrace = copy.doTrace;
this.port = copy.port;
this.jdbcClient = copy.jdbcClient;
@@ -773,6 +780,7 @@
this.userPassword = copy.userPassword;
this.isVerbose = copy.isVerbose;
+ this.doTrace = copy.doTrace;
this.port = copy.port;
this.jdbcClient = copy.jdbcClient;
@@ -800,6 +808,7 @@
DEFAULT_USER_PASSWORD);
hostName = props.getProperty(KEY_HOSTNAME, DEFAULT_HOSTNAME);
isVerbose = Boolean.valueOf(props.getProperty(KEY_VERBOSE)).booleanValue();
+ doTrace = Boolean.valueOf(props.getProperty(KEY_TRACE)).booleanValue();
String portStr = props.getProperty(KEY_PORT);
if (portStr != null) {
try {
@@ -1074,6 +1083,10 @@
* Set the verbosity, i.e., whether debug statements print.
*/
public void setVerbosity( boolean isChatty ) { isVerbose = isChatty; }
+ /**
+ * Set JUnit test method tracing.
+ */
+ public void setTrace( boolean isChatty ) { doTrace = isChatty; }
/**
* Return verbose flag.
@@ -1083,6 +1096,14 @@
public boolean isVerbose() {
return isVerbose;
}
+ /**
+ * Return JUnit test method trace flag.
+ *
+ * @return JUnit test method trace flag.
+ */
+ public boolean doTrace() {
+ return doTrace;
+ }
/**
* <p>
@@ -1180,6 +1201,7 @@
private final String hostName;
private final JDBCClient jdbcClient;
private boolean isVerbose;
+ private boolean doTrace;
private String ssl;
/**