Skip to content

Commit 49ea8ec

Browse files
authored
fix: Should recognize test classes with '$' in their names (#1366)
Signed-off-by: sheche <sheche@microsoft.com>
1 parent 41e71f6 commit 49ea8ec

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111
### Changed
1212
- The `@Test` method will be selected by default when using `Generating Tests...` source action. [#1350](https://github.com/microsoft/vscode-java-test/issues/1350)
1313

14+
### Fixed
15+
- [Bugs fixed](https://github.com/microsoft/vscode-java-test/issues?q=is%3Aissue+is%3Aclosed+label%3Abug+milestone%3A0.34.0)
16+
1417
## 0.33.1
1518
### Fixed
1619
- Reduce the line spacing in test messages [PR#1345](https://github.com/microsoft/vscode-java-test/pull/1345)

java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/util/TestSearchUtils.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.eclipse.jdt.core.search.SearchPattern;
4949
import org.eclipse.jdt.core.search.TypeNameMatch;
5050
import org.eclipse.jdt.core.search.TypeNameMatchRequestor;
51+
import org.eclipse.jdt.internal.corext.refactoring.structure.ASTNodeSearchUtil;
5152
import org.eclipse.jdt.internal.junit.util.CoreTestSearchEngine;
5253
import org.eclipse.jdt.ls.core.internal.JDTUtils;
5354
import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin;
@@ -271,12 +272,12 @@ public static List<JavaTestItem> findDirectTestChildrenForClass(List<Object> arg
271272
continue;
272273
}
273274

274-
final ASTNode node = root.findDeclaringNode(type.getKey());
275-
if (!(node instanceof TypeDeclaration)) {
275+
final TypeDeclaration typeDeclaration = ASTNodeSearchUtil.getTypeDeclarationNode(type, root);
276+
if (typeDeclaration == null) {
276277
continue;
277278
}
278279

279-
final ITypeBinding binding = ((TypeDeclaration) node).resolveBinding();
280+
final ITypeBinding binding = typeDeclaration.resolveBinding();
280281
if (binding == null) {
281282
continue;
282283
}
@@ -344,12 +345,12 @@ public static List<JavaTestItem> findTestTypesAndMethods(List<Object> arguments,
344345
Collections.emptyList();
345346
}
346347

347-
final ASTNode node = root.findDeclaringNode(primaryType.getKey());
348-
if (!(node instanceof TypeDeclaration)) {
348+
final TypeDeclaration typeDeclaration = ASTNodeSearchUtil.getTypeDeclarationNode(primaryType, root);
349+
if (typeDeclaration == null) {
349350
return Collections.emptyList();
350351
}
351352

352-
final ITypeBinding binding = ((TypeDeclaration) node).resolveBinding();
353+
final ITypeBinding binding = typeDeclaration.resolveBinding();
353354
if (binding == null) {
354355
return Collections.emptyList();
355356
}

0 commit comments

Comments
 (0)