问题
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