我有2个功能文件并尝试执行以下操作
**FEATURE 1:**
calling.feature 功能:通过调用功能文件来测试循环
Scenario Outline: Testing loop over feature file
* call read('called.feature') { argument = '<arg>' }
Examples:
|arg|
|"HELLO"|
|"WORLD"|
**FEATURE 2:**
called.feature 特征:在空手道框架中测试循环
场景大纲:测试循环功能 * def callingArg = arg *匹配&#39;&#39; == callingArg 例子: | ARG2 | |&#34; TEST1&#34; | |&#34;世界&#34; |
当我打电话给'Called.feature&#39;使用读入&#39; Calling.feature&#39;我期待它将使用两个特征文件
中的所有示例进行迭代但是空手道一旦发现失败就会退出,在这种情况下,参数&#34; HELLO&#34;从Calling.feature传递,它在“call.feature”中的匹配步骤中失败。例如&#39; TEST1&#39;并且永远不会测试&#39; WORLD&#39;。
有没有办法可以强制空手道完成被调用的所有场景示例?
以下是日志:
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)
答案 0 :(得分:4)
您的格式很难理解。无论如何,空手道应该评估所有示例行,即使出现故障。这是一个简单的例子:
library(raster)
library(spdep)
library(maptools)
r <- raster(nrow=18, ncol=36)
r[] <- runif(ncell(r)) * 10
r[r>8] <- NA
pol <- rasterToPolygons(r, fun=function(x){x>6}, dissolve = T)
plot(pol)
nb <- poly2nb(pol)
create_regions <- function(data) {
group <- rep(NA, length(data))
group_val <- 0
while(NA %in% group) {
index <- min(which(is.na(group)))
nb <- unlist(data[index])
nb_value <- group[nb]
is_na <- is.na(nb_value)
if(sum(!is_na) != 0){
prev_group <- nb_value[!is_na][1]
group[index] <- prev_group
group[nb[is_na]] <- prev_group
} else {
group_val <- group_val + 1
group[index] <- group_val
group[nb] <- group_val
}
}
group
}
region <- create_regions(nb)
pol_rgn <- spCbind(pol, region)
pol2 <- unionSpatialPolygons(pol_rgn, region)
plot(pol2)
Feature:
Scenario Outline:
* call read('called.feature') { a: <value> }
Examples:
| value |
| 1 |
| 2 |
| 3 |
是:
called.feature
它按预期工作。即使第1行和第3行失败,也会执行所有行。所以你可能会使用旧版的空手道。请升级。
编辑:这是在0.8.0:https://github.com/intuit/karate/issues/421
中修复的