【问题标题】:How to create pass threshold for TestCafe Tests on Jenkins如何为 Jenkins 上的 TestCafe 测试创建通过阈值
【发布时间】: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


    【解决方案1】:

    TestCafe provides 一堆指定的记者,它们生成特殊格式的报告。一旦生成,CI 系统(或其中的插件)可以解析报告并根据失败/通过测试的数量执行阈值检查。 TestCafe 文档包括example with Jenkins integration。示例中使用的 Jenkins JUnit 插件尚不支持设置阈值:issue。但是您可以尝试以类似的方式按照指南中的步骤进行操作,但使用 Jenkins xUnit 插件除外。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多