1

I am wondering if others have brought up this question as I could not find anything in my brief searches.

What is the recommended way to exit a test run, at the onset, if something in the config fails, such as authentication, reference to an external file, or missing or invalid value for an expected, passed, parameter, such as karate.env (devv versus dev)?

Current Options tried with no success so far but not a lot of time put into them, to be honest:

  • try/catch blocks
  • return null rather than a config
  • break
mike
  • 383
  • 1
  • 12

1 Answers1

0

There is a new configure abortSuiteOnFailure setting you can experiment with. It is described as follows:

defaults to false, to not attempt to run any more tests upon a failure

So you could do your check, conditionally set this flag if your check fails, and then call karate.fail().

And yes, knowing how to do a try - catch in JS can give you more control.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248