TestCafe团队是否计划正式支持Gherkin(BDD)?如果不是,目前将TestCafe与Gherkins集成的最佳方法是什么?

时间:2018-01-05 21:00:32

标签: bdd gherkin testcafe

我的团队有点像TestCafe,但有一些保留反对采用它。主要是支持Gherking集成。 gherkin-testcafe npm包和样本https://github.com/helen-dikareva/testcafe-cucumber-demo似乎尚未准备好进入黄金时段。目前支持BDD是一种更可靠的方式吗?

2 个答案:

答案 0 :(得分:4)

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

答案 1 :(得分:3)

在办公室与同事交谈后,我们得出结论

的最佳方法
  • 保留我们的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);