Reuse Cucumber steps

前端 未结 5 1803
攒了一身酷
攒了一身酷 2020-11-28 19:44

I want to reuse some Cucumber steps but can\'t seem to find the right way.

I want to write a step like:

Given /^I login with (.*) credentials$/ |type         


        
5条回答
  •  执念已碎
    2020-11-28 20:00

    Best wrap your steps in %{} rather than quotes. Then, you don't need to escape double quotes which you'll need to use frequently.:

    Given /^I login successfully$
      step %{I login with valid credentials}
    end
    
    Given /^I login with (.*) credentials$/ |type|
      # do stuff with type being one of "invalid" or "valid"
    end
    

提交回复
热议问题