我们有在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发布于 2020-10-12 17:20:08
TestCafe provides一组指定的记者,它们生成特殊格式的报告。一旦生成,CI系统(或其中的插件)可以解析报告,并根据失败/通过的测试数量执行阈值检查。TestCafe文档包括一个example with Jenkins integration。示例中使用的Jenkins JUnit插件还不支持设置阈值:issue。但您可以尝试以类似的方式遵循指南中的步骤,除了使用Jenkins xUnit插件。
https://stackoverflow.com/questions/64279404
复制相似问题