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 JUnit4TestClassReference extends JUnit4TestReference { 21 protected final Class <?> fClass; 22 23 public JUnit4TestClassReference(Class <?> clazz) { 24 super(Request.aClass(clazz)); 25 fClass= clazz; 26 } 27 28 public int countTestCases() { 29 return fRunner.testCount(); 30 } 31 32 public String getName() { 33 return fClass.getName(); 34 } 35 36 public void sendTree(final IVisitsTestTrees notified) { 37 sendDescriptionTree(notified, fRunner.getDescription()); 38 } 39 40 private void sendDescriptionTree(final IVisitsTestTrees notified, org.junit.runner.Description description) { 41 if (description.isTest()) { 42 notified.visitTreeEntry(new JUnit4Identifier(description), false, 1); 43 } else { 44 notified.visitTreeEntry(new JUnit4Identifier(description), true, description.getChildren().size()); 45 for (Description child : description.getChildren()) { 46 sendDescriptionTree(notified, child); 47 } 48 } 49 } 50 51 @Override 52 public boolean equals(Object obj) { 53 if (! (obj instanceof JUnit4TestReference)) 54 return false; 55 56 JUnit4TestReference ref= (JUnit4TestReference) obj; 57 return (ref.getIdentifier().equals(getIdentifier())); 58 } 59 60 @Override 61 public int hashCode() { 62 return fClass.hashCode(); 63 } 64 65 public ITestIdentifier getIdentifier() { 66 return new JUnit4Identifier(fRunner.getDescription()); 67 } 68 } 69 | Popular Tags |