How to specify a single scenario with jar file?

2019-07-09 03:51发布

问题:

I am trying to follow this post to run a specific scenario and I am failing at doing this when running the stand-alone version (v0.9.1).

My experiments:

(1) java -Dkarate.options="--name ^bla$" -jar karate.jar features/many.feature

It runs all scenarios from the feature file.

(2) java -Dkarate.options="classpath:features/many.feature --name ^bla$" -jar karate.jar

starts the UI without executing a test case.

What am I missing here?

回答1:

using tags will be a convenient way for this

add a different tag before each scenario and pass the tag name with -t while calling with karate standalone

many.feature

Feature: Many scenario
 @s1
 Scenario: SOne
   * print 'first scenario'
 @s2
 Scenario: Stwo
   * print 'second scenario'

Now pass the scenario tag like,

java -jar karate.jar many.feature -t @s1


标签: karate