File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
org.eclipse.jdt.codemining/src/org/eclipse/jdt/experimental/junit/codemining/tester Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 11package org .eclipse .jdt .experimental .junit .codemining .tester ;
22
3+ import java .util .stream .Stream ;
4+
5+ import org .eclipse .core .runtime .NullProgressMonitor ;
36import org .eclipse .jdt .core .IMethod ;
7+ import org .eclipse .jdt .core .IType ;
8+ import org .eclipse .jdt .core .JavaModelException ;
9+ import org .eclipse .jdt .experimental .JavaCodeMiningPlugin ;
410
511public class JUnit3MethodTester implements IJUnitMethodTester {
612
713 public static final IJUnitMethodTester INSTANCE = new JUnit3MethodTester ();
814
915 @ Override
1016 public boolean isTestMethod (IMethod method ) {
11- return IJUnitMethodTester .isMethod (method , true ) && method .getElementName ().startsWith ("test" );
17+ return IJUnitMethodTester .isMethod (method , true ) && isTestClass (method .getDeclaringType ())
18+ && method .getElementName ().startsWith ("test" );
1219 }
1320
21+ private boolean isTestClass (IType type ) {
22+ try {
23+ return Stream .of (type .newSupertypeHierarchy (new NullProgressMonitor ()).getAllSupertypes (type ))
24+ .filter (t -> "junit.framework.TestCase" .equals (t .getFullyQualifiedName ())).findFirst ().isPresent ();
25+ } catch (JavaModelException e ) {
26+ JavaCodeMiningPlugin .getDefault ().getLog ().error ("isTestClass check for JUnit3 failed." , e );
27+ return false ;
28+ }
29+ }
1430}
Original file line number Diff line number Diff line change 2929 <repository >
3030 <id >photon</id >
3131 <layout >p2</layout >
32- <url >http://download.eclipse.org/releases/photon /</url >
32+ <url >http://download.eclipse.org/releases/2020-06 /</url >
3333 </repository >
3434 <repository >
3535 <id >egit</id >
You can’t perform that action at this time.
0 commit comments