Behave - 重试机制



我们可以在Behave中的Feature文件中重新运行失败的场景。可以借助格式化程序完成这项操作。

可以通过以下命令查看Behave中所有可用的格式化程序−

behave –f help

使用此命令后,可以看到以下屏幕−

Retry Mechanism

重新运行格式化程序用于捕获失败场景,并将它输出到单独的文件中。让我们举一个例子,在这个例子中,我们有一个失败的Feature。

Rerun Formatter

然后,使用以下命令将失败的Feature捕获到另一个Feature文件−

behave –f rerun –o failed_features.feature

可以看到以下内容−

virtualbox

failed_features.feature文件会在项目中生成。其中包含Feature文件名称Payment1.feature,在这个文件中我们遇到失败。

Feature file with the command

若要只重新触发失败的场景,我们必须运行以下所示的命令−

behave @failed_features.feature

将看到以下屏幕−

Re-trigger only Failed Scenario
广告
© . All rights reserved.