Find the example here.
def a = condition ? " karate match statement " : "karate match statement"
Is it possible to do something like this??
Find the example here.
def a = condition ? " karate match statement " : "karate match statement"
Is it possible to do something like this??
This is not recommended practice for tests because tests should be deterministic.
The right thing to do is:
Scenario
match
logicif
keyword and call a second feature file - or you can even set the name of the file to call dynamically via a variablekarate.abort()
can be used to conditionally skip / exit earlyThat said, if you really insist on doing this in the same flow, Karate allows you to do a match
via JS in 0.9.6.RC4 onwards.
See this thread for details: https://github.com/intuit/karate/issues/1202#issuecomment-653632397
The result of karate.match()
will return a JSON in the form { pass: '#boolean', message: '#string' }
If none of the above options work - that means you are doing something really complicated, so write Java interop / code to handle this
For those who still insist on random behavior and conditional logic in UI tests, refer: https://stackoverflow.com/a/76701268/143475