'Karate : executing postman tests

I was exploring karate postman integrations and found below converter.

src/test/java/com/intuit/karate/formats/PostmanConverterTest.java

Above test class works well, it takes a collection file as input and generate one feature file having all requests of collection converted in separate scenarios.

e.g,

Feature: karate-postman-input7858416451077303578

Scenario: SomeDummyScenario
    Given url ...
    And header ...
    And request {.....}
    When method POST

However, it doesn't bother about the scripts we write for postman api testing. Something like below.

pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
})

I am doing a POC which will have a micro-service with an endpoint published. The endpoint will take a postman collection(this will have many rest calls, second depends upon the output of first and third upon the output of second and so on..) as input and convert the collection to feature file on the fly, it will add the "@parallel=false" at the top of feature file to guarantee the sequential execution of scenarios.

The idea behind this is to minimise the efforts for writing karate test cases and directly integrate it with the postman collection.

However, sequential execution will always fail because the script(tests) are not being executed, which are ultimately setting up the variables for next api call.

like, below should be executed before the execution of second api call.

pm.collectionVariables.set("....", responseJson.data.xyz);

I know this is too much to ask for, but any help or any lead would be highly appreciated.

The need is to execute the postman tests after execution of respective converted scenarios.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source