Save This Page
Home » GWT-2009.11.30 » junit » framework » [javadoc | source]
    1   /*
    2    * Copyright 2006 Google Inc.
    3    * 
    4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
    5    * use this file except in compliance with the License. You may obtain a copy of
    6    * the License at
    7    * 
    8    * http://www.apache.org/licenses/LICENSE-2.0
    9    * 
   10    * Unless required by applicable law or agreed to in writing, software
   11    * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   12    * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   13    * License for the specific language governing permissions and limitations under
   14    * the License.
   15    */
   16   package junit.framework;
   17   
   18   /**
   19    * Translatable version of JUnit's <code>TestCase</code>.
   20    */
   21   public class TestCase extends Assert implements Test {
   22   
   23     private String name;
   24   
   25     public int countTestCases() {
   26       return 1;
   27     }
   28   
   29     public String getName() {
   30       return name;
   31     }
   32   
   33     public void runBare() throws Throwable {
   34       setUp();
   35       try {
   36         runTest();
   37       } finally {
   38         try {
   39           tearDown();
   40         } catch (Throwable e) {
   41           // ignore any exceptions thrown from teardown
   42         }
   43       }
   44     }
   45   
   46     public void setName(String name) {
   47       this.name = name;
   48     }
   49   
   50     public String toString() {
   51       return getName() + "(" + this.getClass().getName() + ")";
   52     }
   53   
   54     /**
   55      * Do not override this method, the generated class will override it for you.
   56      */
   57     protected void doRunTest(String name) throws Throwable {
   58     }
   59   
   60     protected void runTest() throws Throwable {
   61       assertNotNull(name);
   62       doRunTest(name);
   63     }
   64   
   65     protected void setUp() throws Exception {
   66     }
   67   
   68     protected void tearDown() throws Exception {
   69     }
   70   
   71   }

Save This Page
Home » GWT-2009.11.30 » junit » framework » [javadoc | source]