Dies ist die Ausgabe des Bündels exec Gurkenlauf. Sie können sehen, dass die @timeout_exception während des Gurkenlaufs gleich Null ist, aber zur Laufzeit gut eingestellt ist.Leere Variablen in Gherkins-Tests
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
Dies ist mein Test, aber obwohl @timeout_exception während des Laufens des Codes arbeitet, ist es während des Tests leer. Wie kann ich testen, ob diese Variable gesetzt ist?
Then(/^the output should be '(.*)'$/) do |expectedException|
expect(@timeout_exception).to eq(expectedException)
end
Dies ist der Ruby-Code.
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 druckt schön "Execution Timeout Error" ist aber während der erwarten (@timeout_exception) leer ...