Reuse Cucumber steps

前端 未结 5 1801
攒了一身酷
攒了一身酷 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条回答
  •  -上瘾入骨i
    2020-11-28 19:55

    Note that the method for calling steps within steps has changed in recent versions of cucumber, which you'll see if you get an error like "WARNING: Using 'Given/When/Then' in step definitions is deprecated, use 'step' to call other steps instead:/path/to/step_definitions/foo_steps.rb:631:in `block in ' ". See the cucumber wiki for details.

    The gist of the change is that you should now use the step or steps methods.

    When /^I make all my stuff shiny$/
      step "I polish my first thing"
    end
    
    When /^I make all my stuff shiny$/
      steps %Q{
        When I polish my first thing
        When I shine my second thing
      }
    end
    

提交回复
热议问题