我们可以实现示例过滤吗?基于空手道
我们可以实现 jbehave
* def request = { item: '#(item)' }
Examples:
|karate.env: |item |
|@dev |778983-110833-110834|
|@qa |848079-419456-419457|
我们需要实现的目标是:
- 空手道DSL以基于示例表中执行测试 空手道的当前值
- 。 '778983-110833-110834'} 如果我在开发环境中进行测试&
{项目: '848079-419456-419457'}
如果我在QA中进行测试。
我无法通过使用karate.env属性来实现此目标,但使用标签实现了它,请参阅下面的示例:
Feature:
Background:
* url 'https://reqres.in/api'
* configure headers = { 'Content-Type': 'application/json'}
Scenario Outline:
* def reqJson = { "name": "name", "job": "<item>"}
And path 'users'
And request reqJson
When method post
Then status 201
And match response.job == '<item>'
@dev
Examples:
| item |
| 111|
@qa
Examples:
| item |
| 222|
在命令行上触发环境= qa:mvn test -dcucumber.options =“ - tags @qa @qa”
在commandline for Environing = dev上触发:mvn test -dcucumber.options =“ - tags @dev”
,
请告诉我是否有其他方法可以实现它,因为我想使用karate.env财产。
Can we achieve 'Filtering on Examples' that we have on Jbehave
Sample below:
* def request = { item: '#(item)' }
Examples:
|karate.env: |item |
|@dev |778983-110833-110834|
|@qa |848079-419456-419457|
What we need to achieve is:
- Karate DSL to execute the tests in Examples table based on the
current value of karate.env - Karate must create a request =
{ item:
if i run tests in dev environment &
'778983-110833-110834' }{ item:
if i run tests in qa.
'848079-419456-419457' }
I was unable to achieve this by using karate.env property but achieved it using the tags, please refer to example below:
Feature:
Background:
* url 'https://reqres.in/api'
* configure headers = { 'Content-Type': 'application/json'}
Scenario Outline:
* def reqJson = { "name": "name", "job": "<item>"}
And path 'users'
And request reqJson
When method post
Then status 201
And match response.job == '<item>'
@dev
Examples:
| item |
| 111|
@qa
Examples:
| item |
| 222|
Triggering on commandline for environment=qa : mvn test -Dcucumber.options="--tags @qa"
Triggering on commandline for environment=dev : mvn test -Dcucumber.options="--tags @dev"
Please let me know if there is any other way of achieving it since i wanted to use karate.env property.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您正在寻找: https://github.com/intub.com/intuit/karate/karate#标签和例子
编辑:对于那些尝试这样做的人,我建议另一种方法,您可以调用这样的功能:
记住,空手道可以从JSON(或CSV)文件中读取,您可以使用它来驱动
示例: https://github.com/intuit/karate/karate#dynamic-scenario-scenario-senario-inline-cenrio-unline < /a>
最后,我不建议这样做太多 - 但是,如果您想实现逻辑以不运行特定
karate.env
值的测试,则可以通过karate.abort()
:只需在<<之后添加该行代码>方案:,并且在需要时会跳过测试。
I think you are looking for this: https://github.com/intuit/karate#tags-and-examples
EDIT: for those landing here trying to do this, I suggest another approach, you can call a feature like this:
Remember, Karate can read from JSON (or CSV) files and you can use that to drive
Examples:
https://github.com/intuit/karate#dynamic-scenario-outlineAnd finally, I don't recommend this much - but if you want to achieve the logic to NOT run a test for a particular
karate.env
value, you can do this viakarate.abort()
:Just add that line just after the
Scenario:
and the test will be skipped when needed.