We are using Karate for testing our application. Since we need to run multiple test with different testdata we used scenario outline passing a json array in the examples. The tests are getting executed properly.
Post execution we need to publish the result to our test management tool. For that, we are trying to use the afterScenario hook as mentioned in karate documentation.
* configure afterScenario =
"""
function(){
var info = karate.info;
karate.log('after', info);
}
"""
After each scenario of the example executed, we see the info details printed, but the error message details, scenario name etc are not populated (title is a value from the json array passed in example section. title is printed in the karate execution report)
Karate.info printed when scenario outline is used:-
14:45:39.744 [main] ERROR com.intuit.karate - status code was: 400, expected: 200, response time: 754, url: ##url removed###, response: ##Response removed###
14:45:39.744 [main] INFO com.intuit.karate - after {
"featureDir": "C:\\Workspace\\Karate_Demo\\target\\test-classes\\com\\test\\Karate_Demo",
"scenarioType": "Scenario Outline",
"featureFileName": "TestIntegration.feature",
"errorMessage": null,
"scenarioDescription": "",
"scenarioName": "<title>"
}
Karate.info printed when scenario is used:-
13:15:54.772 [main] ERROR com.intuit.karate - status code was: 400, expected: 200, response time: 1540, url: ##url removed###, response: ##Response removed###
13:15:54.795 [main] INFO com.intuit.karate - after {
"featureDir": "C:\\Workspace\\Karate_Demo\\target\\test-classes\\com\\test\\Karate_Demo"
"scenarioType": "Scenario",
"featureFileName": "Test.feature",
"errorMessage": "Test.feature:32 - status code was: 400, expected: 200, response time: 1540, url: ##url removed###, response: ##Response removed###,
"scenarioDescription": "",
"scenarioName": "Sample Test"
}
How can i get the karate.info to be populated with errorMessage in case of failures when we use Scenario Outline