Skip to content

Commit c4622eb

Browse files
trancexpressiloveeclipse
authored andcommitted
Match also junit-platform-commons-* file name when detecting a JUnit 6 launch type
Fixes: #2625
1 parent 756f421 commit c4622eb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/util/CoreTestSearchEngine.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
*/
6161
public class CoreTestSearchEngine {
6262

63-
private static final String JUNIT_PLATFORM_SUITE_API_PREFIX= BuildPathSupport.JUNIT_PLATFORM_SUITE_API + "_"; //$NON-NLS-1$
64-
private static final String JUNIT_PLATFORM_COMMONS_PREFIX= BuildPathSupport.JUNIT_PLATFORM_COMMONS + "_"; //$NON-NLS-1$
63+
private static final String JUNIT_PLATFORM_SUITE_API_PREFIX= BuildPathSupport.JUNIT_PLATFORM_SUITE_API;
64+
private static final String JUNIT_PLATFORM_COMMONS_PREFIX= BuildPathSupport.JUNIT_PLATFORM_COMMONS;
6565
private static final String JAR_EXTENSION= ".jar"; //$NON-NLS-1$
6666

6767
public static boolean isTestOrTestSuite(IType declaringType) throws CoreException {
@@ -173,8 +173,8 @@ private static boolean hasJUnitJupiterTestAnnotation(IJavaProject project, int j
173173
if (type != null) {
174174
// check if we have the right JUnit JUpiter version
175175
String filename= type.getPath().lastSegment();
176-
if (filename.startsWith(junitBundlePrefix) && filename.endsWith(JAR_EXTENSION)) {
177-
String versionString = filename.substring(junitBundlePrefix.length(), filename.length() - JAR_EXTENSION.length());
176+
if ((filename.startsWith(junitBundlePrefix + "_") || filename.startsWith(junitBundlePrefix + "-")) && filename.endsWith(JAR_EXTENSION)) { //$NON-NLS-1$ //$NON-NLS-2$
177+
String versionString = filename.substring(junitBundlePrefix.length() + 1, filename.length() - JAR_EXTENSION.length());
178178
Version version = new Version(versionString);
179179
if (version.getMajor() != junitMajorVersion) {
180180
return false;

0 commit comments

Comments
 (0)