Skip to content

Commit

Permalink
junit runner was assuming file, which breaks jar loading ref #529
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Sep 15, 2018
1 parent d2831ed commit c1d1774
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
9 changes: 9 additions & 0 deletions karate-core/src/main/java/com/intuit/karate/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,15 @@ public static void writeToFile(File file, String data) {
public static InputStream toInputStream(String text) {
return new ByteArrayInputStream(text.getBytes(UTF8));
}

public static String removeFileExtension(String path) {
int pos = path.lastIndexOf('.');
if (pos == -1) {
return path;
} else {
return path.substring(0, pos);
}
}

public static String replaceFileExtension(String path, String extension) {
int pos = path.lastIndexOf('.');
Expand Down
5 changes: 4 additions & 1 deletion karate-core/src/main/java/com/intuit/karate/Resource.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.Path;

Expand All @@ -51,6 +50,10 @@ public Resource(Path path, String relativePath) {
this.relativePath = relativePath;
packageQualifiedName = FileUtils.toPackageQualifiedName(relativePath);
}

public String getFileNameWithoutExtension() {
return FileUtils.removeFileExtension(path.getFileName().toString());
}

public String getRelativePath() {
return relativePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static Description getScenarioDescription(String featureName, Scenario s
}

private static String getFeatureName(Feature feature) {
return "[" + feature.getPath().toFile().getName() + "]";
return "[" + feature.getResource().getFileNameWithoutExtension() + "]";
}

@Override
Expand Down

0 comments on commit c1d1774

Please sign in to comment.