我有一个feature
文件:
Scenario: List all accounts in the tenant
Given that Keith has navigated to the tenant account list
When he views the accounts in the table that includes name, name2, name3
Then he should also see 1,2,3,4 in the list
我有一个步骤定义文件:
this.When(/^(.*?) views the accounts in the table that include (.*)$/, (accountInformation: string) => {
return stage.theActorInTheSpotlight().attemptsTo(
ViewAllAccountNames.inTheTableOf(accountInformation)
); });
这是在步骤定义中调用的ViewAllAccountNames
类
constructor(private accName: string) {
}
static inTheTableOf(accName: string) {
return new ViewAllAccountNames(accName);
}
performAs(actor: PerformsTasks): PromiseLike<void> {
return actor.attemptsTo(
See.if(AccountTable.isDisplayingAll, includes(this.accName))
);
}
所以给出所有这些信息,我运行测试并继续获取函数有1个参数,应该有2个(如果是同步或返回一个promise)或3个(如果接受一个回调)(下面是错误)
我无法判断它是否打破了我的代码中的参数或错误
有任何想法吗?
[16:25:27] I/launcher - Running 1 instances of WebDriver
[16:25:27] I/local - Starting selenium standalone server...
[16:25:29] I/local - Selenium standalone server started at http://10.4.31.17:63444/wd/h
ub
Feature: Manage the accounts associated with the tenant
In order to see all accounts for a customer
Keith would like view all accounts in the Account List
Keith would like the account list to display accounts containing Account information
Scenario: List all accounts in the tenant
√ Given that Keith has navigated to the tenant account list
× When he views the accounts in the table that includes name,name2,name3
- Then he should also see 1,2,3,4 in the list
Failures:
1) Scenario: List all accounts in the tenant - e2e\features\get_account_list\get_all_ac
counts.feature:10
Step: When he views the accounts in the table that include name - e2e\features\get_a
ccount_list\get_all_accounts.feature:12
Step Definition: node_modules\serenity-js\src\serenity-cucumber\webdriver_synchronis
er.ts:47
Message:
function has 1 arguments, should have 2 (if synchronous or returning a promise) or
3 (if accepting a callback)
1 scenario (1 failed)
3 steps (1 failed, 1 skipped, 1 passed)
它期望回调参数作为第二个参数。有两种方法可以解决这个问题。
将回调作为参数传递:
this.When(/^(.*?) views the accounts in the table that include (.*)$/, (accountInformation: string, callback) => {
stage.theActorInTheSpotlight().attemptsTo(
ViewAllAccountNames.inTheTableOf(accountInformation)
).then(callback, callback);
});
让函数返回一个承诺:
this.When(/^(.*?) views the accounts in the table that include (.*)$/, function(accountInformation: string) {
return stage.theActorInTheSpotlight().attemptsTo(
ViewAllAccountNames.inTheTableOf(accountInformation)
);
});