Pergunta

I am using rspec and cucumber to run watir tests at sauce labs.

I would like that test name (at sauce labs) is the same as the name of rspec describe block or cucumber feature.

So, if I have rspec file:

describe "something" do
  # teh codez
end

or cucumber file:

Feature: something
# teh codez

I would like that at sauce labs the test is also named something. I know how to say to sauce labs how I want the test to be named, but I do not know how to get rspec describe block name or cucumber feature name when the tests are running.

A bit more context: I have several rspec files and all of them are running in parallel, I am using parallel_tests gem for that. It provides TEST_ENV_NUMBER variable, so I am using it to name tests:

caps[:name] = "job #{ENV['TEST_ENV_NUMBER']}"

So jobs are named: job , job 1, job 2... But I would be better if they were named: user, search, login...

Foi útil?

Solução

You can get the names in the before hooks:

# rspec:

before do
  p [example.description, example.full_description]
end

# cucumber:

Before do |scenario|
 p [scenario.feature.name, scenario.name]
end
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top