001: /*
002: * @(#)JUnitTestCaseEUTest.java
003: *
004: * Copyright (C) 2002-2003 Matt Albrecht
005: * groboclown@users.sourceforge.net
006: * http://groboutils.sourceforge.net
007: *
008: * Permission is hereby granted, free of charge, to any person obtaining a
009: * copy of this software and associated documentation files (the "Software"),
010: * to deal in the Software without restriction, including without limitation
011: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
012: * and/or sell copies of the Software, and to permit persons to whom the
013: * Software is furnished to do so, subject to the following conditions:
014: *
015: * The above copyright notice and this permission notice shall be included in
016: * all copies or substantial portions of the Software.
017: *
018: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
019: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
020: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
021: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
022: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
023: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
024: * DEALINGS IN THE SOFTWARE.
025: */
026:
027: package net.sourceforge.groboutils.junit.v1;
028:
029: import junit.framework.Test;
030: import junit.framework.TestCase;
031: import junit.framework.TestSuite;
032:
033: import java.io.IOException;
034: import java.lang.reflect.Method;
035:
036: /**
037: * Tests the functionality of the JUnit TestCase class for conformance to
038: * expected behaviors.
039: *
040: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
041: * @since March 1, 2002
042: * @version $Date: 2003/02/10 22:52:21 $
043: */
044: public class JUnitTestCaseEUTest extends TestCase {
045: //-------------------------------------------------------------------------
046: // Standard JUnit Class-specific declarations
047:
048: private static final Class THIS_CLASS = JUnitTestCaseEUTest.class;
049:
050: public JUnitTestCaseEUTest(String name) {
051: super (name);
052: }
053:
054: //-------------------------------------------------------------------------
055: // Tests
056:
057: public static class MyTestCase1 extends TestCase {
058: String myName;
059:
060: public MyTestCase1() {
061: // the name of our only test method.
062: super ("test1");
063: }
064:
065: public void test1() {
066: // do nothing
067: }
068:
069: public String getName() {
070: return myName;
071: }
072:
073: public String name() {
074: return getName();
075: }
076:
077: public void runTest() throws Throwable {
078: super .runTest();
079: }
080: }
081:
082: /**
083: * There are some dependencies on TestCase using the internal
084: * "fName" field, as opposed to calling "getName()". You see,
085: * Ant's JUnit reporter task calls "getName()" to make a fancy
086: * printable name, whereas TestCase uses "fName" to reference which
087: * method to call.
088: */
089: public void testRunTestName1() throws Throwable {
090: MyTestCase1 tc = new MyTestCase1();
091: tc.myName = "Just Another Test";
092:
093: // make sure it still works with an overridden getName() method.
094: tc.runTest();
095: }
096:
097: //-------------------------------------------------------------------------
098: // Standard JUnit declarations
099:
100: public static Test suite() {
101: TestSuite suite = new TestSuite(THIS_CLASS);
102:
103: return suite;
104: }
105:
106: public static void main(String[] args) {
107: String[] name = { THIS_CLASS.getName() };
108:
109: // junit.textui.TestRunner.main( name );
110: // junit.swingui.TestRunner.main( name );
111:
112: junit.textui.TestRunner.main(name);
113: }
114:
115: /**
116: *
117: * @exception Exception thrown under any exceptional condition.
118: */
119: protected void setUp() throws Exception {
120: super .setUp();
121:
122: // set ourself up
123: }
124:
125: /**
126: *
127: * @exception Exception thrown under any exceptional condition.
128: */
129: protected void tearDown() throws Exception {
130: // tear ourself down
131:
132: super.tearDown();
133: }
134: }
|