ABS
ABS

Reputation: 61

karate: Picking up feature files from absolute class path

I am following the DemoTestSelected.java sample to run the feature file in my Karate Framework. It's working fine when i run them in intellij. But when i convert it into jar and then run from it, it is throwing the below error.

java.lang.RuntimeException: java.io.FileNotFoundException: file:\C:\Src_path\target\app-jar-with-dependencies.jar!\features\app\app_1.0.4_a.feature (The filename, directory name, or volume label syntax is incorrect)

I explored the Karate Core code and found the below class which might be problem.

 public static URL toFileUrl(String path) {
        path = StringUtils.trimToEmpty(path);
        File file = new File(path);        
        try {
            return file.getAbsoluteFile().toURI().toURL();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

I am stuck here, any help would be appreciated.

Upvotes: 1

Views: 8803

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

First - no one has ever reported this problem and teams normally don't need to bundle tests into a JAR.

Second - if you use the classpath: prefix, you should be able to load feature files from within even JAR files. So please use it and it is documented here: https://github.com/intuit/karate#reading-files

* def result = call read('classpath:some-reusable-steps.feature')

If this does not solve the problem, please follow the instructions here and submit an issue: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue - please explain what you are trying to do differently also.

Upvotes: 0

Related Questions