1 29 package net.sourceforge.groboutils.autodoc.v1.testserver.junit; 30 31 32 import net.sourceforge.groboutils.autodoc.v1.testserver.DefaultTestInfo; 33 import junit.framework.Test; 34 import junit.framework.TestSuite; 35 import junit.framework.TestCase; 36 37 38 39 46 public class JUnitTestInfo extends DefaultTestInfo 47 { 48 49 50 55 public JUnitTestInfo( Object testObj ) 56 { 57 if (testObj == null) 58 { 59 throw new IllegalArgumentException ("no null arguments"); 60 } 61 setSuite( getSuiteName( testObj ) ); 62 setMethod( getMethodName( testObj ) ); 63 } 64 65 66 72 protected String getSuiteName( Object testObj ) 73 { 74 String name; 75 if (testObj instanceof TestSuite) 76 { 77 name = ((TestSuite)testObj).getName(); 78 } 79 else 80 if (testObj instanceof Class ) 81 { 82 name = ((Class )testObj).getName(); 83 } 84 else 85 { 86 name = testObj.getClass().getName(); 87 } 88 return name; 89 } 90 91 92 98 protected String getMethodName( Object testObj ) 99 { 100 String name; 101 if (testObj instanceof TestCase) 102 { 103 name = ((TestCase)testObj).getName(); 104 } 105 else 106 { 107 name = "run"; 108 } 109 return name; 110 } 111 } 112 113 | Popular Tags |