I’m testing an app that sending/receiving alerts.
In my tests, I send an alert, waiting to receive it and then check its content.
So, the steps are (with my functions):
Then /I send an alert/ do
alertTime = Time.new
enterAlertHeader(“New alert - #{ alertTime.sec }”)
pressSendButton
end
Then /I open the alert/ do
pressOnText(“New alert - #{ alertTime.sec }”)
end
In the second step, the alertTime
changed to 0
How can I keep the value?
Do I need to write to a file and then read it?
Use a cucumber World variable. In the example below, the @shared_alert_time is a World variable. I recommend not over using variables to save state. However, sometimes it is necessary and/or convenient.
Then /I send an alert/ do
@shared_alert_time = Time.new
enterAlertHeader("New alert - #{ @shared_alert_time.sec }")
pressSendButton
end
Then /I open the alert/ do
pressOnText("New alert - #{ @shared_alert_time.sec }")
end