Cleanup steps for Cucumber scenarios

前端 未结 2 1604
粉色の甜心
粉色の甜心 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:19

    should also notice that 'Before' and 'After' is global hooks i.e those hooks are run for every scenario in your features file

    If you want the setup and teardown to be run for just few testcases ( grouped by tags) then you need to use taggedHooks, where the syntax is

    Before('@cucumis, @sativus') do
    # This will only run before scenarios tagged
    # with @cucumis OR @sativus.
    end
    
    
    AfterStep('@cucumis', '@sativus') do
    # This will only run after steps within scenarios tagged
    # with @cucumis AND @sativus.
    end
    

    For more info : https://github.com/cucumber/cucumber/wiki/Hooks

提交回复
热议问题