summaryrefslogtreecommitdiff
path: root/qadevOOo/runner/complexlib/ComplexTestCase.java
diff options
context:
space:
mode:
authorSteffen Grund <sg@openoffice.org>2003-03-18 14:55:08 +0000
committerSteffen Grund <sg@openoffice.org>2003-03-18 14:55:08 +0000
commite2af459f23ad60c013a788a2005c13e72013f162 (patch)
tree7a6224f3845e8388472e0ef0de8295dd677642ad /qadevOOo/runner/complexlib/ComplexTestCase.java
parent0e7e7cecc0c4875b87ef0429e9abd13eda3df4a1 (diff)
CHG: added before() and after() methods for tests
Diffstat (limited to 'qadevOOo/runner/complexlib/ComplexTestCase.java')
-rw-r--r--qadevOOo/runner/complexlib/ComplexTestCase.java81
1 files changed, 69 insertions, 12 deletions
diff --git a/qadevOOo/runner/complexlib/ComplexTestCase.java b/qadevOOo/runner/complexlib/ComplexTestCase.java
index eabf9fb3cd94..20f4d9f8d770 100644
--- a/qadevOOo/runner/complexlib/ComplexTestCase.java
+++ b/qadevOOo/runner/complexlib/ComplexTestCase.java
@@ -2,9 +2,9 @@
*
* $RCSfile: ComplexTestCase.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Date: 2003-01-27 16:27:53 $
+ * last change: $Date: 2003-03-18 15:55:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -83,18 +83,46 @@ public abstract class ComplexTestCase implements ComplexTest {
* @param method The name of the test method that should be called.
* @param environment The environment for the test.
*/
- public void executeMethods(DescEntry entry,
- TestParameters environment) {
+ public void executeMethods(DescEntry entry, TestParameters environment) {
// get the environment
param = environment;
log = entry.Logger;
+ String beforeErrorMsg = null;
+
+ // start with the before() method
+ try {
+ Method before = this.getClass().getMethod("before",null);
+ before.invoke(this, null);
+ }
+ catch(java.lang.NoSuchMethodException e) {
+ // simply ignore
+ }
+ catch(java.lang.IllegalAccessException e) {
+ // simply ignore
+ }
+ catch(java.lang.reflect.InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ log.println(t.toString());
+ beforeErrorMsg = "Exception in before() method.\n\r" +
+ t.getMessage();
+ if (beforeErrorMsg == null)
+ beforeErrorMsg = "";
+ log.println("Message: " + beforeErrorMsg);
+ }
//executeMethodTests
for (int i=0; i<entry.SubEntries.length; i++) {
state = true;
message = "";
subEntry = entry.SubEntries[i];
+ // set all test methods on failed, if 'before()' did not work.
+ if (beforeErrorMsg != null) {
+ subEntry.State = beforeErrorMsg;
+ subEntry.hasErrorMsg = true;
+ subEntry.ErrorMsg = beforeErrorMsg;
+ continue;
+ }
Method testMethod = null;
try {
testMethod = this.getClass().getMethod(
@@ -104,31 +132,60 @@ public abstract class ComplexTestCase implements ComplexTest {
catch(java.lang.reflect.InvocationTargetException e) {
Throwable t = e.getTargetException();
log.println(t.toString());
- log.println("Message: " + t.getMessage());
- subEntry.State="PASSED.FAILED";
+ String msg = t.getMessage();
+ log.println("Message: " + msg);
+ subEntry.State=message + (msg == null?"":msg);
+ subEntry.hasErrorMsg = true;
+ subEntry.ErrorMsg = message + "\n" + msg;
continue;
}
catch(java.lang.Exception e) {
log.println(e.getClass().getName());
log.println("Message: " + e.getMessage());
-// e.printStackTrace();
+ String msg = e.getMessage();
+ log.println("Message: " + msg);
subEntry.State="SKIPPED.FAILED";
+ subEntry.hasErrorMsg = true;
+ subEntry.ErrorMsg = (msg == null?"":msg);
continue;
}
subEntry.State = (state?"PASSED.OK":message);
- subEntry.hasErrorMsg = state;
+ subEntry.hasErrorMsg = !state;
subEntry.ErrorMsg = message;
}
+
+ if (beforeErrorMsg == null) {
+ // the after() method
+ try {
+ Method after = this.getClass().getMethod("after",null);
+ after.invoke(this, null);
+ }
+ catch(java.lang.NoSuchMethodException e) {
+ // simply ignore
+ }
+ catch(java.lang.IllegalAccessException e) {
+ // simply ignore
+ }
+ catch(java.lang.reflect.InvocationTargetException e) {
+ Throwable t = e.getTargetException();
+ log.println(t.toString());
+ beforeErrorMsg = "Exception in 'after()' method.\n\r" +
+ t.getMessage();
+ if (beforeErrorMsg == null)
+ beforeErrorMsg = "";
+ log.println("Message: " + beforeErrorMsg);
+ }
+ }
}
public abstract String[] getTestMethodNames();
public abstract String getTestObjectName();
- protected void assure(String msg, boolean state) {
- this.state &= state;
- if (!state) {
- this.message += msg + "\r\n";
+ protected void assure(String msg, boolean s) {
+ state &= s;
+ if (!s) {
+ message += msg + "\r\n";
log.println(msg);
}
}