如何从.feature文件中分离表(空手道框架) [英] How to separate table from .feature file (karate framework)
本文介绍了如何从.feature文件中分离表(空手道框架)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个简单的示例:
Scenario: Table example
* table dogs
| name | age |
| 'Charlie' | 2 |
| 'Jack' | 4 |
| 'Rock' | 9 |
* match dogs == [{name: 'Charlie', age: 2}, {name: 'Jack', age: 4}, {name: 'Rock', age: 9}]
是否可以将表移动到另一个文件,然后将其导入?如果是的话,究竟如何?
Is it possible to move table to another file, and just import it? If yes, how exactly?
预先感谢
推荐答案
在这种情况下,我建议使用JSON而不是表,它可以很好地导入,并具有可被大多数IDE-s编辑的优点.>
For this use case I recommend using JSON instead of a table and it will import nicely and have the advantage of being editable by most IDE-s etc.
* def dogs = read('dogs.json')
* match dogs == [{name: 'Charlie', age: 2}, {name: 'Jack', age: 4}, {name: 'Rock', age: 9}]
您也可以这样做:
* call read('dogs.feature')
* match dogs == [{name: 'Charlie', age: 2}, {name: 'Jack', age: 4}, {name: 'Rock', age: 9}]
在dogs.feature
Feature:
Scenario:
* table dogs
| name | age |
| 'Charlie' | 2 |
| 'Jack' | 4 |
| 'Rock' | 9 |
由于某些团队坚持使用Excel(我不建议这样做),如果适用,也请参考此答案: https://stackoverflow.com/a/47954946/143475
since some teams insist on Excel (which I don't recommend) refer to this answer also if applicable: https://stackoverflow.com/a/47954946/143475
这篇关于如何从.feature文件中分离表(空手道框架)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文