How to run a single row of a Cucumber scenario out

2019-07-08 02:08发布

I'm running tests using RubyMine (forced upon me).

I have some features that use the Scenario Outline and Example format.

Is there a way I can run only a certain row from the Example table?

Example:

 Examples:
  | user_row | row1 | row2 |
  | 1        | 2    | 4    |
  | 51       | 51   | 97   |
  | 98       | 98   | 147  |

I only want to run the test from the 2nd row (user_row 51).

I can't seem to find anything with the help in RubyMine for this.

1条回答
smile是对你的礼貌
2楼-- · 2019-07-08 02:46

Cucumber itself does support running a single example. RubyMine doesn't support it in a nice way, but you can do it with a little extra effort.

To run a single Cucumber example from the command line:

cucumber -f features/your.feature:##

where ## is the line number (over the entire file, not just within the example table) of the example that you want to run.

Disappointingly, RubyMine's Cucumber runner doesn't allow you to run a single line of a Cucumber example: invoking the "Run context configuration" command (control-shift-R in the Mac keymap I'm using) on an example row runs the whole file (it doesn't even just run that scenario), and there's no way to add a line number to a Cucumber run configuration (if you add it to the end of the file name you get an error).

However, you can manually create a generic run configuration which runs a single example:

  • Run → Edit Configurations
  • Click + and choose Gem Command
  • Enter "Gem name" "cucumber", "Executable name" "cucumber", and "Arguments" "features/your.feature:##" (with the appropriate line number in place of ##).
  • Hit OK
  • To run that configuration, click the Run button or type control-R. To debug, click the Debug button or type control-D.

Someone has already filed a request for this feature to be explicitly supported with JetBrains which you can vote for.

查看更多
登录 后发表回答