Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Parse big data in Cucumber using Doc Strings

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 453
    Comment on it

    There are many times when we have to handle a some large data(multiline text) in our Feature file. If we pass the data in data table then every line inside the data table will be considered as new argument. So, data table will not fulfill our requirement.

     

    Let’s take the following example:

     

      Given I login to the site as valid user

      Then "Valid User" should see the following text

      """

    Dummy text

    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.

    Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,

      """

     

    In the above scenario only as we can see that the text that we have to verify is very big. So, the step definition of this step is

     

    Then(/^"([^"]*)" should see the following text$/) do |arg, text|

    pending

    end

     

    The text is not passed as regular expression. So, the only task that we have to perform to parse the big data is that to place the whole text between three double quotes. As soon as cucumber finds the first three double quotes(“””) then it will parsing the data for verification until the next three double quotes is received.

 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: