在空手道测试步骤中使用if-condition的语法是什么?

问题描述 投票:1回答:1

在空手道测试步骤中使用if-condition的语法是什么?

[从空手道GitHub文档上的示例中,我推断这应该可行:

Background:
  * if (env == 'dev') configure ssl = false
  ...

但是,会导致这样的错误:

debug server listening on port: 4711
*** step failed: -unknown-:13 - javascript evaluation failed: if (env == 'dev') 
  configure ssl = false, <eval>:1:28 Expected ; but found ssl
if (env == 'dev') configure ssl = true
                            ^ in <eval> at line number 1 at column number 28

我知道如何解决这个问题并在空手道配置中配置此特定项目,但是由于我想在其他各个步骤上使用if-condition,因此我只是想知道如何将其用作执行此操作的工具如上所述。

karate
1个回答
1
投票

条件逻辑实际上是javascript函数,因此可以使用karate来代替DSL。

尝试,

* if (env == 'dev') karate.configure("ssl", true)

© www.soinside.com 2019 - 2024. All rights reserved.