Lege variables in de gherkins/cucumber test

Pagina: 1
Acties:

Vraag


Acties:
  • 0 Henk 'm!

  • chronoz
  • Registratie: Maart 2010
  • Laatst online: 09-10-2022
Dit is de uitvoer van mijn bundle exec cucumber. Je ziet de @timeout_exception leeg(nil) is tijdens het draaien van cucumber, maar deze werkt fijn als je het script normaal draait... misschien een scope issue?

code:
1
2
3
4
5
6
7
8
9
10
11
12
And the output should be 'Execution Timeout Error: This deployment has taken too long to run'                                     # features/step_definitions/my_steps.rb:309

expected: "Execution Timeout Error: This deployment has taken too long to run"
   got: nil

(compared using ==)
(RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/my_steps.rb:310:in `/^the output should be '(.*)'$/'
features/timeout_lengthy_deploys.feature:25:in `And the output should be 'Execution Timeout Error: This deployment has taken too long to run''

Failing Scenarios:
cucumber features/timeout_lengthy_deploys.feature:11 # Scenario: Normal deploy that times out because it takes too long


Dit is de test, zelf en @timeout_exception werkt wel gewoon tijdens het draaien van de Ruby code, maar is leeg tijdens het draaien van de test. Enige tips?

code:
1
2
3
Then(/^the output should be '(.*)'$/) do |expectedException|
expect(@timeout_exception).to eq(expectedException)
end


Dit is de broncode in Ruby, al weet ik niet of dat erg relevant is.
code:
1
2
3
4
5
6
7
8
9
10
        log.info "Executing '#{command.join(' ')}'"
        begin
            timeout(config['deploy-timeout'].to_i) do
                execute_and_log command
            end
        rescue Timeout::Error => e
            @timeout_exception = "Execution Timeout Error"
            log.error "#{@timeout_exception}"
            raise e
        end

Log.error print netjes "Execution Timeout Error" maar is leeg tijdens de expect(@timeout_exception)... tips zijn erg welkom, ik heb nog weinig ervaring met test-driven development.

[ Voor 20% gewijzigd door chronoz op 04-05-2016 10:39 ]

Alle reacties


Acties:
  • 0 Henk 'm!

  • Bigs
  • Registratie: Mei 2000
  • Niet online
@timeout_exception is een instance variabele. Die is niet zomaar beschikbaar in je test (dat is namelijk een totaal ander object). Je zult dus op een andere manier de uitvoer van je code moeten testen.