0

I have written one scenario to create one file(cmmn file, text like) by calling one API and I am trying to give this file as an input to next scenario in the same feature file for calling another API. Second scenario is not able to pick file which is updated by first scenario and old version of file (before getting updated) is getting picked up and hence getting the error.

Has anyone dealt this before?

Pratap
  • 19
  • 3

1 Answers1

1

This is a bad practice and I totally don't recommend it. All teams are able to run validation and next steps based on the previous responses in memory.

If you really need to do this try the following:

  • make sure you are writing to the /target folder (or build if Gradle)
  • you can use the file: prefix to read() the file in Karate

EDIT: also read this, trying to use 2 Scenario-s for the same single inter-dependent flow is a bad practice: https://github.com/intuit/karate#script-structure

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Thank you. I tried writing file into target folder and its working fine. – Pratap Jan 14 '19 at 10:13
  • When I am trying to execute all code (create file and use file) in the same scenario, code is not able to pick up the updated file. – Pratap Jan 14 '19 at 10:25
  • @pratap no, you must be making some mistake: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue – Peter Thomas Jan 14 '19 at 10:41
  • I am again getting this error with updated version of Java. I am writing one file in target folder of the project in runtime and trying to read the same file in the same scenario but file resource is not getting picked by Karate multipart file. – Pratap Mar 05 '19 at 05:30
  • @Pratap you can comment as many times as you want here - but unless you follow the link in my previous comment, you will not get anywhere. – Peter Thomas Mar 05 '19 at 09:25