karate api testing - How to read tag names from command line to feature file

孤街醉人 提交于 2019-12-11 06:05:33

问题


karate api testing - How to read tag names from command line to feature file

My feature file

Feature: validating tag name reading from maven command line

Background:

Given url baseURL

When param validation = I want to read tagname here

Then method get

Then status 200

@com_status @all @I want to read tagname here

Scenario Outline: Testing tag input scenarios

  • print I want to read tagname here

Command - mvn clean test -Dtest=Runner -DargLine="-Dkarate.env=dev" -Dcucumber.options="--tags @com_status"


回答1:


You cannot. Tags are designed to be passed on the command line to filter scenarios to run - and cannot be retrieved within a test. You can retrieve the tag of a Scenario though: https://github.com/intuit/karate#karate-tags

You can try using karate.properties or something similar to retrieve what was passed on the command-line: https://github.com/intuit/karate#dynamic-port-numbers

Command:

mvn clean test -DcustomName=foo

Feature:

* def customName = karate.properties['customName']

Feel free to contribute this feature if you think it is important.



来源:https://stackoverflow.com/questions/58441844/karate-api-testing-how-to-read-tag-names-from-command-line-to-feature-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!