Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read('./some-file') should be relative to the .feature file in a JAR #433

Closed
slaout opened this issue Jun 22, 2018 · 3 comments
Closed

read('./some-file') should be relative to the .feature file in a JAR #433

slaout opened this issue Jun 22, 2018 · 3 comments

Comments

@slaout
Copy link
Contributor

slaout commented Jun 22, 2018

I have a .feature file that has this line:

  • def isValidTime = read('time-validator.js')

When running in IDE, it's working fine: the .feature file is a real file on disk, in a folder, and Karate succeed to find its sibling time-validator.js file.

But when packing the project in a JAR and running Karate in the JAR, the .feature file cannot find its sibling resource.

Karate should know that the .feature file has been read from the classpath (in the JAR), then reconstruct the full path of the sibling resource to request it to Java's getResource().

NOTE: "../" should also work. In fact, the example above is a simplified version of my problem: I have this tree structure:

  • features/*.feature : the files to run in Karate
  • feature-libs/*.feature : the files to include in other business .feature files
  • scripts/*.js : this is where to load/import/require java-scripts

=> so my need is to make read('../scripts/time-validator.js') work from any .feature file, in IDE or in a JAR.

(NOT talking about the UI: just the runtime)

Yes, read('classpath:scripts/time-validator.js') works both in IDE and in a JAR.
BUT, in the future, I'd like the .feature files to be sometimes in the classpath, sometimes externalised to another folder on disk, so I need relative paths to work without any "classpath:" prefixes nor hard-coded full paths.

@ptrthomas
Copy link
Member

for me this is low priority. all the projects I know are happy with classpath: for re-use via JARs. tagging as "help wanted" and will close if inactive. sounds very much like YAGNI to me.

@ptrthomas
Copy link
Member

closing as wontfix

@ptrthomas
Copy link
Member

@slaout hey this is implemented now in this issue: #520

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants