gpt4 book ai didi

jasmine - Protractor Jasmine Reporter + BDD + Azure DevOps

转载 作者:行者123 更新时间:2023-12-04 17:40:59 25 4
gpt4 key购买 nike

我想以 BDD 风格编写 Jasmine End 2 结束测试。据我了解,这意味着我有差不多 4 个方面:

  • 特色
  • 场景
  • 刺激或事件
  • 要确保的结果

从我天真的观点来看,我会像这样为“个人详细信息”功能创建一个测试:

// Feature
describe('Showing Individual Details', () => {
let individualDetailsPage: IndividualDetailsPage;

beforeEach(() => {
individualDetailsPage = new IndividualDetailsPage();
});

// Scenario - New Individual
describe('Given a new Individual', () => {
beforeEach(async () => {
await individualDetailsPage.navigateToDetails('-1');
});

// Incoming Event
describe('When the Details are loaded', () => {
// Ensure outcome
it('Then all Controls are empty', async () => {
expect(individualDetailsPage.firstNameInput.text).toBe('');
expect(individualDetailsPage.lastNameInput.text).toBe('');
expect(individualDetailsPage.birthdateInput.text).toBe('');
});

// Ensure outcome
it('Then the save button is disabled', () => {
expect(individualDetailsPage.saveButton.isEnabled).toBe(false);
});
});
});
});

因此,对于 Individual Details 功能,如果设置了新的 Individual,则 Controls 应该为空,并且禁用保存按钮。仍然从天真的角度来看,这似乎没问题。同时运行测试,我看到:

enter image description here

这看起来不错。现在是有趣的部分:我想将此更改发布到 Azure DevOps,因此我在 Protractor 配置中使用以下代码:

  onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
var jasmineReporters = require('jasmine-reporters');
var junitReporter = new jasmineReporters.JUnitXmlReporter({
savePath: 'testresults',
filePrefix: 'e2e-tests',
consolidateAll: true
});

jasmine.getEnv().addReporter(junitReporter);
}

不幸的是,XML 看起来像这样:

 <testsuite name="Showing Individual Details" timestamp="2019-02-04T18:23:33" hostname="localhost" time="2.035" errors="0" tests="0" skipped="0" disabled="0" failures="0">
</testsuite>
<testsuite name="Showing Individual Details.Given a new Individual" timestamp="2019-02-04T18:23:33" hostname="localhost" time="2.033" errors="0" tests="0" skipped="0" disabled="0" failures="0">
</testsuite>
<testsuite name="Showing Individual Details.Given a new Individual.When the Details are loaded" timestamp="2019-02-04T18:23:33" hostname="localhost" time="2.033" errors="0" tests="2" skipped="0" disabled="0" failures="0">
<testcase classname="Showing Individual Details.Given a new Individual.When the Details are loaded" name="Then all Controls are empty" time="1.106" />
<testcase classname="Showing Individual Details.Given a new Individual.When the Details are loaded" name="Then the save button is disabled" time="0.927" />
</testsuite>

由于 Azure DevOps 似乎只检查名称,因此我看到:

enter image description here

我的问题:我不确切地知道我的问题出在哪里。我没有找到任何关于 Jasmine 的“真实”BDD 的好资源,而且 Jasmine Reporter 似乎不能配置那么多:https://github.com/larrymyers/jasmine-reporters

因此,我的代码是完全错误的,还是实际上是报告者?如果是这种情况,是否有替代方案或者我是否需要以某种方式“扁平化”XML?

最佳答案

我同意上面的评论,创建您自己的记者声音是可行的方法。您可以根据需要格式化内容。

我最近回复了另一个关于 Jasmine 记者的问题here .我将我的测试结果重新格式化为一个 JSON 对象,并在每次测试完成后将它们存储在 amazons dynamoDB 中。

如有任何问题,请告诉我。

关于jasmine - Protractor Jasmine Reporter + BDD + Azure DevOps,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54522498/

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