本文介绍了空手道afterFeature函数执行在本地运行时效果很好,但在通过Jenkins运行时失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

空手道 afterFeature 函数在本地运行时效果很好,但在Jenkins中运行时失败,我得到assertion failed: assert evaluated to false: responseStatus == 200 || responseStatus == 404.而responseStatus应该是200 or 404.

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.

代码段

主要功能片段

  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

Jenkins的日志:responseStatus的断言失败,但不会记录 responseStatus 的实际值.

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'); }

此外,我在Jenkins中看不到执行 afterFeature 的日志,这也不是Cucumber报告的一部分,我无法进行进一步的分析.

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.

推荐答案

最有可能是空手道的旧版本.尝试0.9.5

Most likely an old version of Karate. Try 0.9.5

如果您仍然无法解决此问题-请按照以下过程操作: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

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

另外,请阅读以下其他选项: https://stackoverflow.com/a/60944060/143475

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

这篇关于空手道afterFeature函数执行在本地运行时效果很好,但在通过Jenkins运行时失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 18:38