Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Cucumber - Reuse the value of any variable

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 800
    Comment on it

    We have a scenario in which first we have to fill the form and then assert the values filled in the form. This can be achieved by two ways:

     

    Call assertion step form submission step but both the steps should be under the same step definition file. If we have to assert some specific fields only then we cannot use this pattern for assertion.

     

    The other way is to store the values in hooks.rb under a variable and then call that instance variable in any step definition.

     

    Before('@TC029', '@TC030') do
      @category = "Automation"
      @blog_title = "Test title"
      @dummy_text = "This is a dummy text for testing"
      @dummy_tags = "Test"
    end

     

    Now the value of all the four variables are available for the scenarios that were tagged with @TC029 and @TC030. We can use these values in our step definitions in different files also.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: