【发布时间】:2020-10-12 17:20:08
【问题描述】:
我们有在 Jenkins 环境中运行回归套件的 TestCafe.js UI 测试。
我们正在探索一种创建机制的方法,其中我们可以为测试套件设置一定的通过阈值,以使 Jenkins 作业状态为通过/失败。
即如果 98% + 测试通过,则将测试作业标记为通过。
在 XUnit 项目下,同样可以使用 XUnit 测试插件等来实现。 示例参考:How can I have Jenkins fail a build only when the number of test failures changes?
How to fail a Jenkins job based on pass rate threshold of testng tests
How to not mark Jenkins job as FAILURE when pytest tests fail
基于 TestCafe 的测试是否可以通过 TestCafe 自定义/通过一些 Jenkins 插件进行类似的测试?
我们的 Jenkins 文件:
#!groovy
pipeline {
environment {
CI = 'true'
}
options {
buildDiscarder(logRotator(numToKeepStr: '50'))
disableResume()
ansiColor('xterm')
}
agent none
// Define the stages of the pipeline:
stages {
stage('setup') {
steps {
script {
cicd.setupBuild()
}
}
}
// Use the make target to run tests:
stage('Tests') {
agent any
steps {
script {
cicd.withSecret(<keys>) {
cicd.runMake("test")
}
}
}
post {
cleanup {
archiveArtifacts artifacts: "screenshots/**", allowEmptyArchive: true
}
}
}
}
post {
success {
script { cicd.buildSuccess() }
}
failure {
script {
slackSend channel: "#<test-notifications-channel>", color: 'bad', message: "Regression tests failed or unstable <${env.RUN_DISPLAY_URL}|${env.JOB_NAME}>"
cicd.buildFailure()
}
}
}
}
enter code here
【问题讨论】:
标签: jenkins testing continuous-integration automated-tests testcafe