Jenkins 詹金斯显示,量角器测试即使失败,也是成功的
当控制台明确显示失败时,Jenkins显示量角器测试成功 我在代码中添加了expect()和fail(),但无法使脚本失败,以避免误报 脚本代码Jenkins 詹金斯显示,量角器测试即使失败,也是成功的,jenkins,protractor,automated-tests,Jenkins,Protractor,Automated Tests,当控制台明确显示失败时,Jenkins显示量角器测试成功 我在代码中添加了expect()和fail(),但无法使脚本失败,以避免误报 脚本代码 async fillCategories(): Promise<void> { try { await this.helper.compareText(this.projectNamePath, this.projectName); await this.helper.com
async fillCategories(): Promise<void> {
try {
await this.helper.compareText(this.projectNamePath, this.projectName);
await this.helper.compareText(this.projectStatus, 'Started');
await browser.wait(ExpectedConditions.presenceOf(this.verticalDots), 500);
await this.helper.compareText(this.commonElements.lCurrentStepName, 'Categories');
await this.helper.click(this.firstCheckbox);
await this.helper.click(this.btnSaveAndContinue);
} catch (error) {
console.log(`Something wrong while filling categories.`);
fail(`Something wrong while filling categories.`);
expect(`Test`).toBe('Fail');
}
}
詹金斯控制台:
**************************************************
* Failures *
**************************************************
1) abc Project Smoke Test should create a project in abc
[31m- [39m[31mExpected '' to be 'QA Automation'.[39m
[31m- [39m[31mFailed: Something wrong while filling categories.[39m
[31m- [39m[31mExpected '2' to be 'Purposes'.[39m
[31m- [39m[31mExpected '3' to be 'Ripts'.[39m
[31m- [39m[31mFailed: project creation failed TimeoutError: Wait timed out after 30031ms[39m
Executed 2 of 2 specs[31m (1 FAILED)[39m in 4 mins 17 secs.
[16:02:18] I/launcher - 0 instance(s) of WebDriver still running
[16:02:18] I/launcher - chromeANY #01 passed
No mail will be sent out, as 'Dev Hourly Smoke Test #461' does not have a result yet. Please make sure you set a proper result in case of pipeline/build scripts.
Finished: SUCCESS
看到上面最后一行的成功了吗
团队产出
所以我使用shell命令。我玩的把戏是这样的量角器
ERROR=0
protractor conf.js || ERROR=1
exit $ERROR
若量角器通过,错误保持为零,当您退出0时,它会将您的构建标记为成功
| | ERROR=1
仅在量角器出现故障时执行,覆盖该值并以失败的代码1
退出
我希望您能从这里开始,为您的案例做一个比较问题是您在可重用函数中使用了
expect
。在it
block中尝试验证步骤失败是失败,对吗?我正在试图理解它是如何工作的。它不必与你的量角器代码有任何关系,请附上你的jenkins shell脚本instead@SergeyPleshakov詹金斯的脚本是什么?对不起,我不熟悉。你是说量角器不会让詹金斯的工作失败。所以我假设你有一份测试的工作。每个作业都应该有执行步骤/脚本。AFAIK有两种类型的脚本—groovy用于管道,shell用于其他所有脚本。通常,如果您转到作业/配置,它将位于“构建”部分“执行shell”步骤下
ERROR=0
protractor conf.js || ERROR=1
exit $ERROR