01: /*
02: * Copyright 2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.commons.math;
18:
19: import junit.framework.AssertionFailedError;
20: import junit.framework.TestCase;
21:
22: /**
23: * A TestCase that retries tests when assertions fail.
24: * <p>
25: * If one or more tests throw an AssertionFailedError, all tests are
26: * repeated one time.
27: * <p>
28: * Errors or exceptions other than AssertionFailedError do not lead to retries.
29: *
30: * @version $Revision: 155427 $ $Date: 2005-02-26 06:11:52 -0700 (Sat, 26 Feb 2005) $
31: */
32: public class RetryTestCase extends TestCase {
33:
34: public RetryTestCase() {
35: super ();
36: }
37:
38: public RetryTestCase(String arg0) {
39: super (arg0);
40: }
41:
42: /**
43: * Override runTest() to catch AssertionFailedError and retry
44: */
45: protected void runTest() throws Throwable {
46: try {
47: super .runTest();
48: } catch (AssertionFailedError err) {
49: // System.out.println("Retrying " + this.getName());
50: super.runTest();
51: }
52: }
53:
54: }
|