1 12 13 package org.eclipse.jdt.internal.junit4.runner; 14 15 import org.eclipse.jdt.internal.junit.runner.ITestIdentifier; 16 import org.eclipse.jdt.internal.junit.runner.IVisitsTestTrees; 17 import org.junit.runner.Description; 18 import org.junit.runner.Request; 19 20 public class JUnit4TestMethodReference extends JUnit4TestReference { 21 private final Description fDescription; 22 23 public JUnit4TestMethodReference(Class <?> clazz, String methodName) { 24 super(Request.method(clazz, methodName)); 25 fDescription = Description.createTestDescription(clazz, methodName); 26 } 27 28 public int countTestCases() { 29 return 1; 30 } 31 32 public void sendTree(IVisitsTestTrees notified) { 33 notified.visitTreeEntry(getIdentifier(), false, 1); 34 } 35 36 public String getName() { 37 return fDescription.toString(); 38 } 39 40 @Override 41 public boolean equals(Object obj) { 42 if (! (obj instanceof JUnit4TestMethodReference)) 43 return false; 44 45 JUnit4TestMethodReference ref = (JUnit4TestMethodReference) obj; 46 return (ref.fDescription.equals(fDescription)); 47 } 48 49 @Override 50 public int hashCode() { 51 return fDescription.hashCode(); 52 } 53 54 @Override 55 public String toString() { 56 return fDescription.toString(); 57 } 58 59 public ITestIdentifier getIdentifier() { 60 return new JUnit4Identifier(fDescription); 61 } 62 } 63 | Popular Tags |