当前位置: 首页 > 知识库问答 >
问题:

空手道:当我调用带有场景大纲的特性文件时,在特性文件上循环失败

田宇
2023-03-14

我有2个功能文件,正在尝试执行下面的操作

**FEATURE 1:** 

calling.feature feature:通过调用特性文件进行测试循环

Scenario Outline: Testing loop over feature file
* call read('called.feature') { argument = '<arg>' }

Examples:
|arg| 
|"HELLO"|
|"WORLD"|


**FEATURE 2:** 

feature feature:空手道框架中的测试循环

当我在“calling.feature”中使用read调用“called.feature”时,我希望它将在两个功能文件中的所有示例中迭代使用

但是空手道一旦发现失败就会退出,在本例中,当参数“hello”从calling.feature传递时,它在“called.feature”(例如“test1”)的匹配步骤中失败,并且从不测试“world”。

有没有一种方法我可以强制空手道完成所有的场景示例在called.feature???

以下是日志:

calling: [com.intuit.karate.exception.KarateException: path: $, actual: 'HELLO', expected: 'TEST1', reason: not equal
    at com.intuit.karate.StepDefs.matchNamed(StepDefs.java:540)
    at com.intuit.karate.StepDefs.matchEquals(StepDefs.java:526)
    at ✽.* match fileName == "TEST1"(called.feature:16)
, com.intuit.karate.exception.KarateException: path: $, actual: 'WORLD', expected: 'TEST1', reason: not equal
    at com.intuit.karate.StepDefs.matchNamed(StepDefs.java:540)
    at com.intuit.karate.StepDefs.matchEquals(StepDefs.java:526)
    at ✽.* match fileName == "TEST1"(called.feature:16)
, com.intuit.karate.exception.KarateException: feature call (loop) failed: called.feature
caller: calling.feature
items: [{mdbName=HELLO}, {mdbName=WORLD}]
errors:
-------
feature call (loop) failed at index: 0
caller: calling.feature
arg: {mdbName=HELLO}

path: $, actual: 'HELLO', expected: 'TEST1', reason: not equal
-------
feature call (loop) failed at index: 1
caller: calling.feature
arg: {mdbName=WORLD}

path: $, actual: 'WORLD', expected: 'TEST1', reason: not equal
    at com.intuit.karate.Script.evalFeatureCall(Script.java:1636)
    at com.intuit.karate.Script.call(Script.java:1579)
    at com.intuit.karate.Script.callAndUpdateConfigAndAlsoVarsIfMapReturned(Script.java:1669)
    at com.intuit.karate.StepDefs.callAndUpdateConfigAndVars(StepDefs.java:571)
    at ✽.* call read('called.feature') mdbData(calling.feature:9)

共有1个答案

公西鸿博
2023-03-14

你的格式很难理解。无论如何,Karate应该计算所有示例行,即使有一个失败。这里有一个简单的例子:

Feature:    
Scenario Outline:

* call read('called.feature') { a: <value> }    

Examples:
| value |
| 1     |
| 2     |
| 3     |

称为d.feature是:

Feature:
Scenario:

* match a == 2

和预期的一样工作。即使第1行和第3行失败,也会执行所有行。所以你可能在玩一个老版本的空手道。请升级。

编辑:这在0.8.0:https://github.com/intuit/karate/issues/421中已经修复

 类似资料: