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

穿精又带淫゛_ 提交于 2021-02-16 21:00:40

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/61180204/karate-afterfeature-function-execution-works-fine-when-run-locally-but-fails-whe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!