簡體   English   中英

空手道:在后台定義 json 時,動態場景大綱不起作用

[英]karate: Dynamic Scenario Outline not working when json is defined in background

Feature: Dynamic Scenario Outline
 Background: 
  * def kittens = [{"name":"abc"},{"name":"def"}]
 Scenario Outline: cat name: <name> 
  * print <name> 
 Examples: 
  | kittens |

執行此代碼后的錯誤是:

 org.graalvm.polyglot.PolyglotException: ReferenceError: "kittens" is not defined

然而,如果我將這個 JSON 直接放入示例中,這將工作並執行 2 次。 通過如下圖:

Examples: 
  | [{"name":"abc"},{"name":"def"}] |

為什么我得到“小貓”未定義,知道嗎?

在新版本的空手道中, Background不像這樣工作。

請閱讀: https://github.com/karatelabs/karate/releases/tag/v1.3.0

所以嘗試:

Feature:

@setup
Scenario:
* def kittens = [{"name":"abc"},{"name":"def"}]  

 Scenario Outline: cat name: <name> 
  * print name 
 Examples: 
  | karate.setup().kittens |

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM