You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected token value for the same step that is getting executed for the second time in the same scenario is different from the expected value. Basically the token value stored during the execution of first step is displayed while execution of same step for the second time.
✅ What did you expect to see?
During execution, for each step fresh token value should be fetched whether the step or token value is same or not.
@token
Feature: Testing Token
Scenario: Testing Token Functionality For The Same Steps In The Same Scenario
When I should see desired message as 'This goal is scored by PLAYER1.'
When I should see desired message as 'This goal is scored by PLAYER1.'
Create a step definition class.
File name-step_def_steps.rb
Then /^I should see desired message as '(.+(?:PLAYER)(?:\d+).+)'$/ do |expected_msg|
actual_msg = 'This goal is scored by JACK REACHER.'
/^#{expected_msg}$/.match? actual_msg
end
Create a parametertype class where we have to put the required token.
File name-parameter_types.rb
ParameterType(
name: 'token',
regexp: /.+(?:PLAYER)(?:\d+).+/,
type: String,
transformer: -> (msg) do
puts 'Message fetched by step-> ' + msg # This statement is placed here to check the value of message that msg variable is fetching from the step in feature file.
test_data = {
:player1 => 'JACK REACHER',
:player2 => 'JOHN WICK',
}
case msg
when /\PLAYER(?:\d+)/
msg.gsub!(/PLAYER(?:\d+)/, test_data[:player1])
else
raise 'This token is not supported'
end
end
)
#You can execute the feature with the command--> bundle exec cucumber -t @token,
📚 Any additional context?
As per my opinion, the value of token is stored every time when the operation is performed and if the value of the passed token is same in the second step also then it will display the same value. However if the value of token is different in both steps, then it will work properly.
Console outupt-
@token
Feature: Testing Token
Scenario: Testing Token Functionality For The Same Steps In The Same Scenario # features/test_token.feature:4
Message fetched by step-> This goal is scored by PLAYER1.
When I should see desired message as 'This goal is scored by JACK REACHER. # features/step_definitions.rb:1
Message fetched by step-> This goal is scored by JACK REACHER.
When I should see desired message as 'This goal is scored by JACK REACHER. # features/step_definitions.rb:1
This token is not supported (RuntimeError)
When the step When I should see desired message as 'This goal is scored by PLAYER1.' is called again, then the parameter_types transformer (msg), should have This goal is scored by PLAYER1. But the actual message is fetched from the previous step.
QUESTION- Is that how supposed to work or is it a bug??
The text was updated successfully, but these errors were encountered:
I don't see anything failing in your code execution. Again if you could ideally show us in the form of a failing test or a git repo? It sounds like you are seeing something you're not expecting.
Could you also strip down as much redundant information as possible. see SSCCE.org for information
👓 What did you see?
Expected token value for the same step that is getting executed for the second time in the same scenario is different from the expected value. Basically the token value stored during the execution of first step is displayed while execution of same step for the second time.
✅ What did you expect to see?
During execution, for each step fresh token value should be fetched whether the step or token value is same or not.
📦 Which tool/library version are you using?
Ruby-3.2.1
Cucumber-8.0
watir-7.6
🔬 How could we reproduce it?
File name-test.feature
File name-step_def_steps.rb
File name-parameter_types.rb
#You can execute the feature with the command-->
bundle exec cucumber -t @token
,📚 Any additional context?
As per my opinion, the value of token is stored every time when the operation is performed and if the value of the passed token is same in the second step also then it will display the same value. However if the value of token is different in both steps, then it will work properly.
Console outupt-
When the step
When I should see desired message as 'This goal is scored by PLAYER1.'
is called again, then the parameter_types transformer (msg), should haveThis goal is scored by PLAYER1.
But the actual message is fetched from the previous step.QUESTION- Is that how supposed to work or is it a bug??
The text was updated successfully, but these errors were encountered: