Performing the function of a cucumber several times

I am trying to run the cucumber function several times (i.e. 500 times). Is there any way to do this, than I have to enter one command each time? I assume this can be done with Rake? I am not a specialist in using rakes or cucumbers.

Thank your help.

thanks

+6
ruby rake cucumber
source share
5 answers
ruby -e '500.times { `cucumber` }' 
+8
source share

In your rake file:

 require 'rubygems' require 'cucumber' require 'cucumber/rake/task' cuke_task = Cucumber::Rake::Task.new(:features) do |t| t.cucumber_opts = "features --format pretty" end task :feature, :name, :times do |task,args| puts "Executing feature: #{args[:name]} #{args[:times]} times" cuke_task.cucumber_opts = "features/#{args[:name]}" args[:times].to_i.times { Rake::Task[:features].execute } end 

First I create a default oculation task that will perform all my functions and format them for me.

After that, I define a rake command called feature , which will take two parameters of the function name and execution times .

Then I increment the cuke task to use the name function that I specified, and then completed the Rake task with the number of times indicated.

 $ rake feature['login.feature',500] 
+5
source share

This can also be done using a script outline and nested steps:

Create a scenario diagram with N examples. The script will be executed N times.

 Feature: Login Robustness Scenario Outline: I want to be assured that login works consistently When i run login # "<login>" repeatedly, it never fails Examples: | login | | repeated login # 1 | | repeated login # 2 | | repeated login # N | … 

Use existing steps as nested steps within the outline of the script that you define:

 When(/^i run login \# "(.*?)" repeatedly, it never fails$/) do |login_run_number| puts login_run_number steps %{ Given I am at initial login, Core When A correct username and password are entered, Native (Core) Then I should be logged in, Native (Core) } end 

Benefits:

  • Only one report is written for the entire test run; No N reports to view results.
  • It uses the existing functions of a cucumber; no changes to the framework needed.
  • Testers already understand how scripting scripts work.

Disadvantages:

  • Ugly, multi-line .feature file.
+3
source share

Mark your function with something like: @ AndIwillwalk500miles

 @AndIwillwalk500miles Feature: Walk A Mile 'That I can walk a mile in another man shoes.' Scenario: That I can walk a Mile in loafers Given I am wearing loafers And I start at point A When I walk a mile Then I am at point B 

Create a ruby ​​file in the features/support/ folder. The convention looks like env.rb or hooks.rb , but it doesn't matter what you call it as long as it is in this folder. I call my env.rb Paste the following code into it:

 Around('@AndIwillwalk500miles') do |scenario, block| 500.times { block.call } end 

When you're done, remove the tag. If you want to run only one script from your function, just mark it. This way you can run as many or several tests as you want 500 times, without having to use Rake or mess with the command line. This is especially useful if you are moving between operating system environments.

+1
source share

This is a dumb job, but try this.

cucumber functions / functions file.feature /../ features / file.feature

until the file path is identical every time, you can use as many ".." as you want

-2
source share

All Articles