question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Karate DSL - karate.info is not populated when Scenario outline is used with JSON Array in Examples

See original GitHub issue

We are using Karate for testing our application. We need to run multiple test with different testdata that is passed as a JSONArray from our test management tool. The JSONArray returned is used in Example section of Scenario Outline. The tests are getting executed properly.

Post execution to publish the result to our test management tool we tried using 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 when the example is a JSON Array. It works fine when the example is a Cucumber Table.

Karate.info printed when scenario outline is used with JSONArray in example:-

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 outline is used with cucumber example table:-

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"
}

Karate Version: 0.9.5 Java Version - Open JDK 8 / 11 Intellij 2019.3.4 Attached Sample Project ScenarioOutline.zip

Attached Project has following features. ScenarioOutlineExample_With_JSONArray.feature - Feature with ScenarioOutline where example passed as a JSON Array ScenarioOutlineExample_With_Table.feature - Feature with ScenarioOutline where example passed as a normal Cucumber table

Command to run the tests:- mvn clean test

Issue Raised based on StackOverflow Question:- https://stackoverflow.com/questions/61610048/karate-dsl-karate-info-is-not-populated-when-used-with-scenario-outline

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ptrthomascommented, Jun 10, 2020

@jervarghese you already have 0.9.6.RC3 - please follow us on Twitter or LinkedIn if you want updates

0reactions
ptrthomascommented, Aug 24, 2020

0.9.6 released

Read more comments on GitHub >

github_iconTop Results From Across the Web

karate.info is not populated when Scenario outline is used ...
We are using Karate for testing our application. We need to run multiple test with different testdata that is passed as a JSONArray...
Read more >
karate.info is not populated when used with Scenario outline
Since we need to run multiple test with different testdata we used scenario outline passing a json array in the examples. The tests...
Read more >
Karate | Test Automation Made Simple.
Karate is the only open-source tool to combine API test-automation, mocks, performance-testing and even UI automation into a single, unified framework.
Read more >
Step-3: Reading data files, Scenario Outline, CSV files, Callers
That doesn't sound good, it is not the best practice. Karate has a feature that you can read JSON files directly in the...
Read more >
Getting Started With Karate Test Framework for API
In this tutorial I want to give you a quickest start with the Karate Test Framework, and how to run and debug Karate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found