Azure devops 在Azure DevOps上运行Jasmine测试作为自动构建过程的一部分

Azure devops 在Azure DevOps上运行Jasmine测试作为自动构建过程的一部分,azure-devops,jasmine,Azure Devops,Jasmine,考虑到构建中有一个Angular应用程序作为它的一部分,这里有Jasmine测试。我必须做些什么才能将这些测试结果作为构建的一部分发布,更好的是,在成功执行所有Jasmine测试时检查构建结果?您可以通过以下脚本和任务执行此操作: 跑 使用任务发布测试结果 使用任务发布代码覆盖率结果 在文件中,这可能如下所示: # perform unit-tests and publish test and code coverage results - script: | npx ng test -

考虑到构建中有一个Angular应用程序作为它的一部分,这里有Jasmine测试。我必须做些什么才能将这些测试结果作为构建的一部分发布,更好的是,在成功执行所有Jasmine测试时检查构建结果?

您可以通过以下脚本和任务执行此操作:

跑 使用任务发布测试结果 使用任务发布代码覆盖率结果 在文件中,这可能如下所示:

# perform unit-tests and publish test and code coverage results
- script: |
    npx ng test --watch=false --karmaConfig karma.conf.ci.js --code-coverage
  displayName: 'perform unit tests'    

- task: PublishTestResults@2
  condition: succeededOrFailed()
  inputs:
    testResultsFormat: 'JUnit'
    testResultsFiles: '**/TESTS-*.xml'
  displayName: 'publish unit test results'

- task: PublishCodeCoverageResults@1
  displayName: 'publish code coverage report'
  condition: succeededOrFailed()
  inputs:
    codeCoverageTool: Cobertura
    summaryFileLocation: '$(Build.SourcesDirectory)/coverage/cobertura-coverage.xml'
    failIfCoverageEmpty: true     

您可以通过以下脚本和任务执行此操作:

跑 使用任务发布测试结果 使用任务发布代码覆盖率结果 在文件中,这可能如下所示:

# perform unit-tests and publish test and code coverage results
- script: |
    npx ng test --watch=false --karmaConfig karma.conf.ci.js --code-coverage
  displayName: 'perform unit tests'    

- task: PublishTestResults@2
  condition: succeededOrFailed()
  inputs:
    testResultsFormat: 'JUnit'
    testResultsFiles: '**/TESTS-*.xml'
  displayName: 'publish unit test results'

- task: PublishCodeCoverageResults@1
  displayName: 'publish code coverage report'
  condition: succeededOrFailed()
  inputs:
    codeCoverageTool: Cobertura
    summaryFileLocation: '$(Build.SourcesDirectory)/coverage/cobertura-coverage.xml'
    failIfCoverageEmpty: true     

@uminder的Azure配置是正确的

我想补充两件事,这样答案就完整了。这是创建junit报告和覆盖率文件所必需的,所以您可以稍后在azure管道中引用它们

junit和coverage(如果没有)向karma.config.js报告 当然你需要安装它

npm安装-d karma junit reporter

我还想在coverageReporter中添加一个cobertura到karma.config.js中

 coverageReporter:  { 
 ....
 reporters: [
     ...
     { type: 'cobertura' } // TO BE ADDED        
 ]
}


@uminder的Azure配置是正确的

我想补充两件事,这样答案就完整了。这是创建junit报告和覆盖率文件所必需的,所以您可以稍后在azure管道中引用它们

junit和coverage(如果没有)向karma.config.js报告 当然你需要安装它

npm安装-d karma junit reporter

我还想在coverageReporter中添加一个cobertura到karma.config.js中

 coverageReporter:  { 
 ....
 reporters: [
     ...
     { type: 'cobertura' } // TO BE ADDED        
 ]
}