Cucumber > Saving State up to a Step



  • I am using Cucumber through IntelliJ and am working on fixing a broken test. I was wondering when debugging, is there a way to save the state of the system up to a certain step in the feature file, if they all pass. For example, take this exaggerated example below

       Given I am a New User
       And There is an Event on a certain date
       When I log in
       And Go to the Events page
       And I select the Event
       And I go to the Payments Page
       And I attempt to pay with credit card
       (cont)
    

    In the example above, if I am checking why credit card payments were failing in the test, I'd have to rerun the test loads of times to get the system into the state I wanted it in (user, event created). Is there a way to save the state of the system once a step passes? So, therefore, running the test above and it failing on the last step, means that if I run it again it will restore the state of the system based on a snapshot of how it was after the last step and continue to run from the next step. Example...

       Given I am a New User
       (snapshot of the system with a new user is recorded)
       And There is an Event on a certain date
       (snapshot of the system with a new user and event is recorded)
       When I log in
       (snapshot of the system with a new user and event is recorded and the user is logged in)
    

    I worked in a place that used an in-house test runner and they were able to do it, just wondering if this is a feature that is available?



  • Cucumber executes the step definitions glue that you provide it with, so it can't in any way control the state of your system. If you need to save snapshots of the system after each step, call a function that would do that for you at the end of every step.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2