How to run a single cucumber scenario in Intellij?

2019-04-19 15:05发布

I have a simple problem - I want to run a single Cucumber scenario, but I can't seem to find any option/configuration for that.

I have 5-6 scenarios and I can set up configurations to run all tests, but It takes too much time, when I am correcting one scenario...

3条回答
做自己的国王
2楼-- · 2019-04-19 15:16

Tag the feature file with any name, you may add multiple tags separated with spaces.

Eg : @acceptance @regression

Now, add below options in the end of VM otions by editing configuration

-Dcucumber.options="--tags @acceptance"

Run the test and it will only trigger the feature files tagged with @acceptance

You can either set the configuration one for acceptance and one for regression or edit the configuration everytime you run it.

查看更多
▲ chillily
3楼-- · 2019-04-19 15:21

you can call single Scenario by calling it line number simply assuming your Scenario starts on line

-16 Scenario: description
Given: etc

you can run it like this

cucumber features\test.feature:16

查看更多
萌系小妹纸
4楼-- · 2019-04-19 15:39

You can specify a scenario as a run argument, either though Intellij or at the command line:

As jhilan mentions - In Ruby the command looks like this:

cucumber path/to/file.feature:33

In cucumber-jvm, it looks like this:

-Dcucumber.options="classpath:<package-path>/<file>.feature:<line>"

E.g -Dcucumber.options="classpath:com/company/my_feature.feature:6"

To set this up in Intellij, take a look at their docs on the subject of run configurations

I know this is an old post but it's still the second highest Google result when search "executing cucumber by scenario". So I thought it deserved a more thorough answer.

查看更多
登录 后发表回答