我的团队有点喜欢TestCafe,但对采用它有一些保留意见。最主要的是支持小黄瓜集成。gherkin-testcafe npm 包和示例 https://github.com/helen-dikareva/testcafe-cucumber-demo 似乎还没有准备好进入黄金时段。
这是目前支持 BDD 的更可靠方式吗?
我来自TestCafe团队。现在,我们不打算在不久的将来添加此功能。但我想小黄瓜测试咖啡馆是一个很好的开始。这是一个开源模块,因此社区很有可能会添加所需的功能。如果您愿意,您可以自己继续执行此操作。
在与办公室的同事交谈后,我们得出结论,最好的方法是
- 保持我们的BDD流程,
- 使用TestCafe和
- 在 Typescript 中编写测试,而不添加对不是最可实现的 JavaScript 包的依赖
就是在编写TestCafe测试时只使用一些约定。例如,假设您获得以下小黄瓜文件:
Feature: Application
As an administrator
I want to be able to view and manage Applications in my account
Scenario: Verify creating and deleting an application
Given I am in the login page
When I login to console with allowed user
And I go to Applications page
And I add an application
Then the application is added in the application page
然后,feature.ts 文件将如下所示:
import {Selector} from 'testcafe';
import {LoginPageModel} from '../pagemodels/login.pagemodel';
import {ApplicationPageModel} from '../pagemodels/application.pagemodel';
let applicationPageModel: ApplicationPageModel = new ApplicationPageModel();
let loginPageModel: LoginPageModel = new LoginPageModel();
fixture(`Feature: Application
As a administrator
I want to be able to view and manage Applications in my account
`);
let scenarioImplementation = async t => {
let stepSuccess: boolean;
stepSuccess = await loginPageModel.goToPage(t);
await t.expect(stepSuccess).eql(true, 'Given I am in the login page');
stepSuccess = await loginPageModel.login(t);
await t.expect(stepSuccess).eql(true, 'When I login to console with
allowed user');
stepSuccess = await applicationPageModel.selectPage(t);
await t.expect(stepSuccess).eql(true, 'And I go to Applications page');
stepSuccess = await applicationPageModel.addApplication(t);
await t.expect(stepSuccess).eql(true, 'And I add an application');
stepSuccess = await applicationPageModel.verifyAddedApplication(t);
await t.expect(stepSuccess).eql(true, 'Then the application is added in
the application page');
};
test(`Scenario: Verify creating and deleting an application
Given I am in the login page
When I login to console with allowed user
And I go to Applications page
And I add an application
Then the application is added in the application page`,
scenarioImplementation);