空手道:当我调用具有场景大纲的功能文件时,在功能文件上循环失败 [英] KARATE: Loop over a feature file fails when I call a feature file with scenario outline
问题描述
我有2个功能文件,并尝试执行以下操作
I have 2 feature files and trying to perform below operation
**FEATURE 1:**
calling.feature 功能:通过调用功能文件来测试循环
calling.feature Feature: Test loop over by calling a feature file
Scenario Outline: Testing loop over feature file
* call read('called.feature') { argument = '<arg>' }
Examples:
|arg|
|"HELLO"|
|"WORLD"|
**FEATURE 2:**
被称为功能 功能:在空手道框架中进行测试循环
called.feature Feature: Test loop over in Karate framework
方案概述:测试循环功能 * def调用Arg = arg *匹配''== callingArg 例子: | arg2 | |"TEST1" | |世界" |
Scenario Outline: Testing loop over feature * def callingArg = arg * match '' == callingArg Examples: |arg2| |"TEST1"| |"WORLD"|
当我使用"Calling.feature"中的read调用"Called.feature"时,我期望它会在两个功能文件中的所有示例中重复使用
When I call 'Called.feature' using read in 'Calling.feature' I was expecting it will iterate using across all the examples in both feature file
但是空手道一旦发现失败就退出,在这种情况下,当从Calling.feature传递参数"HELLO"时,它会在"call.feature"中的匹配步骤(例如"TEST1")中失败,并且从不测试"WORLD".
but Karate exits whenever it finds the failure, in this case when parameter "HELLO" is passed from Calling.feature it fails during match step in 'called.feature' for example 'TEST1' and never tests for 'WORLD'.
有没有一种方法可以强迫空手道完成被调用场景中的所有场景示例?
Is there a way I can force Karate to complete all the scenario examples in the 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)
推荐答案
您的格式很难理解.无论如何,即使发生故障,空手道也应该评估所有示例行.这是一个简单的示例:
Your formatting is very hard to understand. Anyway Karate is supposed to evaluate all example rows even if there is a failure. Here is a simple example:
Feature:
Scenario Outline:
* call read('called.feature') { a: <value> }
Examples:
| value |
| 1 |
| 2 |
| 3 |
called.feature
是:
Feature:
Scenario:
* match a == 2
它可以按预期工作.即使第1行和第3行失败,也会执行所有行.因此,您可能正在使用旧版的空手道.请升级.
And it works as expected. Even though rows 1 and 3 fail, all rows are executed. So you may be on an old version of Karate. Please upgrade.
此问题已在0.8.0中修复: https://github.com/intuit /karate/issues/421
This was fixed in 0.8.0: https://github.com/intuit/karate/issues/421
这篇关于空手道:当我调用具有场景大纲的功能文件时,在功能文件上循环失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!