KARATE: Loop over a feature file fails when I call a feature file with scenario outline

此生再无相见时 提交于 2019-12-08 06:09:46

问题


I have 2 feature files and trying to perform below operation

**FEATURE 1:** 

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

Scenario Outline: Testing loop over feature * def callingArg = arg * match '' == callingArg Examples: |arg2| |"TEST1"| |"WORLD"|

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

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???

Below is the logs:

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:


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     |

And called.feature is:

Feature:
Scenario:

* match a == 2

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.

EDIT: This was fixed in 0.8.0: https://github.com/intuit/karate/issues/421



来源:https://stackoverflow.com/questions/49802845/karate-loop-over-a-feature-file-fails-when-i-call-a-feature-file-with-scenario

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