Need to pass Testcase ID(variable) and testcase status_code from my scenario to afterScenario() in karate framework. I want to execute afterScenario once scenario run and update the status of testcase with pass or fail.

Background:
        * url 'https://myorganisation.com/tokenService' 
        * def status_code = 49
        * configure afterScenario =
      """
      function() {
      karate.call('classpath:com/test/setup/SetStatus.feature',{ caseID: '#(case_id)', status: '#(status_code)'});    
      }
      """


    Scenario: Create token - POSITIVE
        * def case_id = 12345
        Given path '/oauth/token'
        And param grant_type = 'client_credentials'
        And request {}
        And header Content-Type = 'application/json'
        And header Accept = 'application/json'
        When method POST
        Then status 200
        And set status_code = 50

0 Answers