如何使用Jenkins为Cypress/Cucumber/Typescript项目中的未决测试用例配置Allure报告生成?

o3imoua4  于 2023-06-05  发布在  Jenkins
关注(0)|答案(1)|浏览(195)

我使用Cypress,Cucumber with Typescript项目。到目前为止,当我们只有通过/失败的测试用例时,Allure报告成功生成。但是当我使用Cucumber标签时,没有生成报告(显示NaN,诱惑结果文件夹不存在),这会创建一些处于挂起状态的测试用例。在Jenkins/Docker环境下测试运行,这里是我的管道脚本。

pipeline {
  agent {
    kubernetes {
        yaml """
apiVersion: v1
kind: Pod
spec:
  containers:
  - name: cypress
    image: cypress/included:12.10.0
    command:
    - cat
    tty: true
  - name: git
    image: alpine/git
    command:
    - cat
    tty: true
  securityContext:
    runAsUser: 1000
    runAsGroup: 3000
    fsGroup: 2000    
  """
    }
  }

  options {
    timeout(time: 60, unit: 'MINUTES')
    buildDiscarder(logRotator(numToKeepStr: '10'))
  }

  stages {
    stage('Clone repository') {
      steps {
        container('git') {
            git(
               url: 'tests/explorer.git',
               credentialsId: 'tests-explorer',
               branch: 'dev'
            )
        }
      }
    }
    stage('Cypress') {
      steps {
        container('cypress') {
          dir('ui-auto-tests') {
           sh '''
            CYPRESS_CACHE_FOLDER=/tmp/.cypress-cache \\
            npm install
            ./node_modules/.bin/cypress install --force
            '''
            sh '''
            NO_COLOR=1 \\
            CYPRESS_CACHE_FOLDER=/tmp/.cypress-cache \\
            npx cypress run --browser chrome --env allure=true
            '''
          }
        }
      }
    }
  } 
  
   post {
          always {
            script {
              allure([
                includeProperties: false,
                jdk: '',
                properties: [],
                reportBuildPolicy: 'ALWAYS',
                results: [[path: 'ui-auto-tests/allure-results']]
              ])
            }
          }
          success {
              slackSend channel: 'reporting-qa', color: '#00FF00',
              message: "${env.JOB_NAME}\n Build ID:  ${env.BUILD_ID}\n Status: Success\n Duration: ${currentBuild.durationString}\n Allure: (<${env.BUILD_URL}/allure|open>)"
          }
          failure {
              slackSend channel: 'reporting-qa', color: 'FF0000',
              message: "${env.JOB_NAME}\n Build ID:  ${env.BUILD_ID}\n Status: Failed\n Duration: ${currentBuild.durationString}\n Allure: (<${env.BUILD_URL}/allure|open>)"
          }
          aborted {
              slackSend channel: 'reporting-qa', color: '808080',
              message: "${env.JOB_NAME}\n Build ID:  ${env.BUILD_ID}\n Status: Pending\n Duration: ${currentBuild.durationString}\n Allure: (<${env.BUILD_URL}/allure|open>)"
          }
    }
}

我试过所有的状态。对于挂起测试用例,状态为始终、已更改、已修复、回归、已中止、成功、不成功、不稳定、失败、未构建、清理

jobtbby3

jobtbby31#

上面的脚本,我想运行以下查询

npx cypress run --browser chrome --env allure=true --env TAGS='"@Smoke"'

npx cypress run --browser chrome --env allure=true

所以问题是固定的,当我更新上述查询如下

npx cypress run --browser chrome --env allure=true, TAGS='"@Smoke"'

相关问题