1 17 package org.apache.tools.ant.taskdefs.optional.junit; 18 19 import junit.framework.Test; 20 import junit.framework.TestCase; 21 import junit.framework.TestResult; 22 23 25 public class JUnitVersionHelperTest extends TestCase { 26 27 public JUnitVersionHelperTest(String name) { 28 super(name); 29 } 30 31 public void testMyOwnName() { 32 assertEquals("testMyOwnName", 33 JUnitVersionHelper.getTestCaseName(this)); 34 } 35 36 public void testNonTestCaseName() { 37 assertEquals("I'm a foo", 38 JUnitVersionHelper.getTestCaseName(new Foo1())); 39 } 40 41 public void testNoStringReturn() { 42 assertEquals("unknown", 43 JUnitVersionHelper.getTestCaseName(new Foo2())); 44 } 45 46 public void testNoGetName() { 47 assertEquals("unknown", 48 JUnitVersionHelper.getTestCaseName(new Foo3())); 49 } 50 51 public void testNameNotGetName() { 52 assertEquals("I'm a foo, too", 53 JUnitVersionHelper.getTestCaseName(new Foo4())); 54 } 55 56 public void testNull() { 57 assertEquals("unknown", JUnitVersionHelper.getTestCaseName(null)); 58 } 59 60 public static class Foo implements Test { 61 public int countTestCases() {return 0;} 62 public void run(TestResult result) {} 63 } 64 65 public static class Foo1 extends Foo { 66 public String getName() {return "I'm a foo";} 67 } 68 69 public static class Foo2 extends Foo { 70 public int getName() {return 1;} 71 } 72 73 public static class Foo3 extends Foo { 74 } 75 76 public static class Foo4 extends Foo { 77 public String name() {return "I'm a foo, too";} 78 } 79 80 } 81 | Popular Tags |