Skip to content

Commit 2e03b52

Browse files
authored
Merge pull request Idean#123 from Hugal31/fix/junit-subdirectories
Fix junit unable to locate test in sub-directories
2 parents fc7b867 + aa56da5 commit 2e03b52

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sonar-swift-plugin/src/main/java/org/sonar/plugins/swift/surefire/SwiftSurefireParser.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ protected void saveResults(Resource testFile, UnitTestClassReport report) {
158158

159159
@Nullable public Resource getUnitTestResource(String classname) {
160160
String fileName = classname.replace('.', '/') + ".swift";
161+
String wildcardFileName = classname.replace(".", "/**/") + ".swift";
161162

162163
InputFile inputFile = fileSystem.inputFile(fileSystem.predicates().hasPath(fileName));
163164

@@ -168,10 +169,10 @@ protected void saveResults(Resource testFile, UnitTestClassReport report) {
168169
if (inputFile == null) {
169170
List<InputFile> files = ImmutableList.copyOf(fileSystem.inputFiles(fileSystem.predicates().and(
170171
fileSystem.predicates().hasType(InputFile.Type.TEST),
171-
fileSystem.predicates().matchesPathPattern("**/" + fileName))));
172+
fileSystem.predicates().matchesPathPattern("**/" + wildcardFileName))));
172173

173174
if (files.isEmpty()) {
174-
LOGGER.info("Unable to locate test source file {}", fileName);
175+
LOGGER.info("Unable to locate test source file {}", wildcardFileName);
175176
} else {
176177
/*
177178
* Lazily get the first file, since we wouldn't be able to determine the correct one from just the
@@ -190,4 +191,3 @@ private void saveMeasure(Resource resource, Metric metric, double value) {
190191
}
191192
}
192193
}
193-

0 commit comments

Comments
 (0)