Skip to content

Commit

Permalink
Fix junit unable to locate test in sub-directories
Browse files Browse the repository at this point in the history
Closes Idean#117
  • Loading branch information
Hugal31 committed Feb 15, 2018
1 parent a404d5f commit aa56da5
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ protected void saveResults(Resource testFile, UnitTestClassReport report) {

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

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

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

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

0 comments on commit aa56da5

Please sign in to comment.