1

我的团队有点像 TestCafe,但对采用它有一些保留意见。主要是支持 Gherkin 集成。gherkin-testcafe npm 包和示例https://github.com/helen-dikareva/testcafe-cucumber-demo似乎还没有准备好迎接黄金时段。

它是目前支持 BDD 的更可靠的方式吗?

4

2 回答 2

5

我来自 TestCafe 团队。现在,我们不打算在不久的将来添加此功能。但我想gherkin-testcafe是一个不错的入门模块。这是一个开源模块,因此社区很有可能会添加所需的功能。如果你愿意,你可以继续自己做。

于 2018-01-09T11:58:32.823 回答
4

在与办公室的同事交谈后,我们得出结论,最好的方法是

  • 保持我们的 BDD 流程,
  • 使用 TestCafe 和
  • 在 Typescript 中编写测试,而不添加对不是最可靠的 javascript 包的依赖项

只是在编写 TestCafe 测试时使用一些约定。例如,假设您有以下 Gherkin 文件:

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);
于 2018-01-22T17:21:21.813 回答