gpt4 book ai didi

javascript - 如何在我的功能场景 Cucumber.js 中使用标签?

转载 作者:数据小太阳 更新时间:2023-10-29 04:52:27 25 4
gpt4 key购买 nike

如何在我的功能场景中使用标签?

如何知道调用我函数的场景?

实际上我有一种情况:

Feature: create module feature
As a admin
I want to use create module

@createModule
Given I am logged as 'ADMIN'
And I am on "/admin/create"
Then The "book_id" field should be empty

我想在我的函数中使用我的标签@createModule 然后:

this.Then(/^The "?([^"]*)"? field should be empty$/, function (el) {

if (myModule === @createModule) {
...
} else if {
...
}

return main_po.checkIsEmptyElement(this, el);
});

我想获取我的标签@createModule,指定调用的场景,或者其他替代方案,我想知道什么场景调用我的函数。

Solved :

我补充说:

this.Before(function (scenario, callback) {
var tags = scenario.getTags();

this.current_module = tags[0].getName();

callback();
});

和我的功能:

this.Then(/^The "?([^"]*)"? field should be empty$/, function (el) {

if (this.current_module === @createModule) {
...
} else if {
...
}

return main_po.checkIsEmptyElement(this, el);
});

最佳答案

这是我用来获取 Cucumber 3.0.7 的功能或场景标签的内容

let myTags = feature.pickle.tags;
myTags.forEach(element => {
logger.info(`My Tags: ${element.name}`);

});

关于javascript - 如何在我的功能场景 Cucumber.js 中使用标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34154323/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com