Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

automated tests - 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.

question from:https://stackoverflow.com/questions/65908224/getting-url-error-karaterunner-testapi-testapi-feature12-java-net-urisyntaxex

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...