Kuldeep Jain
Kuldeep Jain

Reputation: 8598

Karate afterFeature function execution works fine when run locally but fails when run through Jenkins

Karate afterFeature function execution works fine when run locally but fails when run through Jenkins, I get assertion failed: assert evaluated to false: responseStatus == 200 || responseStatus == 404. Whereas the responseStatus should either be 200 or 404.

Code Snippet

main.feature snippet

  Background:
    ...
    * def myName1 = 'karate-test-name'
    * configure afterFeature = function(){ karate.call('cleanup.feature'); }
  ...
  ...

cleanup.feature

@ignore
Feature: To cleanup after main.feature execution. This Feature is not supposed to be run individually.

  Background:
    * url myUrl

  Scenario: Delete
    * print 'In "cleanup.feature", If exists delete: ' + myName1
    Given path 'v1/myapi/',myName1,''
    And header Content-Type = 'application/json; charset=utf-8'
    And request {}
    When method delete
    Then assert responseStatus == 200 || responseStatus == 404

Logs from Jenkins: The assertion for the responseStatus fails, but it does not log the actual value of the responseStatus.

23:03:15.448 [pool-1-thread-4] ERROR com.intuit.karate - assertion failed: assert evaluated to false: responseStatus == 200 || responseStatus == 404
23:03:15.450 [pool-1-thread-4] ERROR com.intuit.karate - feature call failed: cleanup.feature
arg: null
cleanup.feature:16 - assert evaluated to false: responseStatus == 200 || responseStatus == 404
23:03:15.451 [pool-1-thread-4] ERROR com.intuit.karate - javascript function call failed: 
cleanup.feature:16 - assert evaluated to false: responseStatus == 200 || responseStatus == 404
23:03:15.451 [pool-1-thread-4] ERROR com.intuit.karate - failed function body: function(){ karate.call('cleanup.feature'); }

Moreover, I do not see the logs for execution of afterFeature in Jenkins, neither it is part of the Cucumber report for me to do further analysis.

Upvotes: 2

Views: 1210

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

Most likely an old version of Karate. Try 0.9.5

If you still can't solve this - please follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

And also, please read this for other options: https://stackoverflow.com/a/60944060/143475

Upvotes: 1

Related Questions