1

Currently, we abort features/scenarios on various conditions, such as result in previous call did not contain desired data, but is it possible to add a text string to the karate.abort() as such?

  * def resultFound = karate.get('resultFound', karate.abort('test'))
or possible allow something like this
  * def resultFound = karate.get('resultFound', { karate.log('test'); karate.abort(); })
mike
  • 383
  • 1
  • 12

1 Answers1

0

Not likely, there is a karate.fail() that does work the way you want. karate.abort() is not recommended for common use, in your case (my personal opinion) it sounds like you are attempting to over-engineer your tests: https://stackoverflow.com/a/54126724/143475

IMO tests should set up a specific scenario, with a predictable response which you just assert on and move on.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Not overengineering, but adding checks rather than recreating the wheel for different accounts. For example, if I run a set of test in one environment, and the response returns the desired response (say account is over a year old), but when testing another account, that is only 11 months, I do not want various subsequent endpoint to be tested. I could do specific account feature files, but that is not maintainable, hence the conditional stops at this point. I could use karate.fail, but that would result in a failure versus simply not executing future steps. – mike Mar 07 '23 at 18:56
  • @mike just conditionally call a second feature with the "extra" checks. won't that work ? if you want karate to work differently, you are welcome to contribute code – Peter Thomas Mar 07 '23 at 19:45
  • 1
    I just implemented in a 2 step process without the karate.get but as a conditional check - `* if (skipFlag) {karate.log('skipFlag is set to true so further calls cannot be ran!'); karate.abort();}` – mike Mar 08 '23 at 15:12