Cleanup steps for Cucumber scenarios

前端 未结 2 1601
粉色の甜心
粉色の甜心 2020-12-29 07:21

Is there a way to define the cleanup steps for all of the scenarios for a feature in Cucumber? I know that Background is used to define the setup steps for each

2条回答
  •  醉话见心
    2020-12-29 08:03

    You can use an After hook that will run after each scenario:

    After do
      ## teardown code
    end
    

    There's also a Before hook that will allow you to set up state and/or test data prior to the scenario:

    Before do
      ## setup code
    end
    

    The Before and After hooks provide the functionality of setup and teardown from Test::Unit, and they are generally located in hooks.rb in the features/support directory.

提交回复
热议问题