因此,如果我总共有4个测试,如果第一个测试失败,那么我想对第一个测试进行快速失败,然后我想继续运行其他三个测试/功能文件。
我不喜欢它现在正在做什么,一旦一个测试失败,它将失败,并且它将不会运行任何其他功能文件。
任何想法?
我尝试过黄瓜选项:
'fail-fast': true
但如果发生故障将停止执行
如果测试失败,如果您想跳过功能文件中的其余测试,则需要执行以下操作:
@feature_<something unique>
之类的标签。Before
和After
挂钩以跟踪标签并确定功能是否失败:// a place to track all of the failed scenarios.
const failedFeatures = [];
// identifies the feature tag using the pickle object.
function getFeature(pickle) {
return pickle.tags.map(i => i.name).filter(i => i.indexOf('@feature_') === 0)[0];
}
// determines if the feature has failed, if it has then skip this test.
Before(function ({ pickle }) {
const feature = getFeature(pickle);
if (failedFeatures.indexOf(feature) >= 0) {
return 'skipped';
}
});
// if a test has failed, record that this feature has also failed.
After(function ({ pickle, result }) {
const feature = getFeature(pickle);
if (result.status === 'failed') {
failedFeatures.push(feature);
}
});