当夜间观察测试断言在Browserstack中失败时,无法执行Jenkins作业 [英] Failing a Jenkins job when nightwatch test assertion fails in Browserstack

查看:109
本文介绍了当夜间观察测试断言在Browserstack中失败时,无法执行Jenkins作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Jenkins作业,它通过Nightwatch.js框架在Browserstack上运行Selenium测试.我们有一套完整的测试程序,可以使守夜人在不同的流程中运行,并且我们需要一种方法,在所有测试运行之后,将通过/失败值返回给Jenkins.

I have a Jenkins job that runs Selenium tests on Browserstack via the Nightwatch.js framework. We have an entire suite of tests that nightwatch runs in separate processes, and we need a way to get the pass/fail value back to Jenkins after all tests have run.

我一直试图使用Nightwatch钩子teardown在每个模块的末尾使用if(this.results.failed) { take action }运行一段代码,但是我无法弄清楚要执行什么操作詹金斯(Jenkins)工作容易失败.

I have been trying to use the Nightwatch hook teardown to run a piece of code at the end of each module with if(this.results.failed) { take action }, but I can't figure out what action I need to take in order to make the failure accessible to the Jenkins job.

我最初的想法是创建一个环境变量,并在测试失败时将其设置为false,但是我认为每个进程都在单独的子shell中运行,因此无法访问由测试模块创建/修改的变量.

My initial thought was to create an environment variable, and set it to false any time a test fails, but I think each process runs in a separate subshell, so the variables created/modified by the test module are not accessible.

我的第二个想法是在globals模块中创建一个计数器,但是当被全局after方法引用时,该值不会按预期增加.

My second idea was to create a counter in the globals module, but that value does not increment as expected when referenced by a global after method.

推荐答案

我能够使用 Jenkins Log Parser插件在控制台输出包含字符串"TEST FAILURE"的情况下无法通过测试.

I was able to solve this issue using the Jenkins Log Parser Plugin to fail the test in the event that the console output contains the string "TEST FAILURE".

这是通过创建一个包含一行的规则文件来完成的:

This was accomplished by creating a rule file that contains a single line:

error /TEST FAILURE/

这篇关于当夜间观察测试断言在Browserstack中失败时,无法执行Jenkins作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆