001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     * 
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     * 
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    
018    package org.apache.commons.math;
019    
020    import junit.framework.AssertionFailedError;
021    import junit.framework.TestCase;
022    
023    /**
024     * A TestCase that retries tests when assertions fail.
025     * <p>
026     * If one or more tests throw an AssertionFailedError, all tests are 
027     * repeated one time.  
028     * <p>
029     * Errors or exceptions other than AssertionFailedError do not lead to retries.
030     *
031     * @version $Revision: 762087 $ $Date: 2009-04-05 10:20:18 -0400 (Sun, 05 Apr 2009) $
032     */
033    public abstract class RetryTestCase extends TestCase {
034    
035        public RetryTestCase() {
036            super();
037        }
038    
039        public RetryTestCase(String arg0) {
040            super(arg0);
041        }
042        
043        /**
044         *  Override runTest() to catch AssertionFailedError and retry
045         */
046        @Override
047        protected void runTest() throws Throwable {
048            try {
049                super.runTest();
050            } catch (AssertionFailedError err) {
051                // System.out.println("Retrying " + this.getName());
052                super.runTest();
053            }    
054        }
055    
056    }