Skip to content

Commit 02532d3

Browse files
authored
fix: identify naming in junit (#1847)
* fix: identify naming in junit * fix: update
1 parent b8d3098 commit 02532d3

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

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

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import java.util.Collections;
6363
import java.util.HashMap;
6464
import java.util.HashSet;
65+
import java.util.LinkedHashMap;
6566
import java.util.LinkedList;
6667
import java.util.List;
6768
import java.util.Map;
@@ -223,14 +224,26 @@ public static List<JavaTestItem> findTestPackagesAndTypes(List<Object> arguments
223224
}
224225
}
225226

226-
final List<JavaTestItem> result = new LinkedList<>();
227+
// Merge packages that share the same ID (e.g. same package name across different source sets)
228+
final Map<String, JavaTestItem> mergedPackages = new LinkedHashMap<>();
227229
for (final JavaTestItem item : testItemMapping.values()) {
228230
if (item.getTestLevel() == TestLevel.PACKAGE) {
229-
result.add(item);
231+
final JavaTestItem existing = mergedPackages.get(item.getId());
232+
if (existing != null) {
233+
if (item.getChildren() != null) {
234+
for (final JavaTestItem child : item.getChildren()) {
235+
if (existing.getChildren() == null || !existing.getChildren().contains(child)) {
236+
existing.addChild(child);
237+
}
238+
}
239+
}
240+
} else {
241+
mergedPackages.put(item.getId(), item);
242+
}
230243
}
231244
}
232245

233-
return result;
246+
return new LinkedList<>(mergedPackages.values());
234247
}
235248

236249
/**

0 commit comments

Comments
 (0)