作为自动生成过程的一部分,在Azure DevOps上运行Jasmine测试 [英] Running Jasmine tests on Azure DevOps as part of automated build process
本文介绍了作为自动生成过程的一部分,在Azure DevOps上运行Jasmine测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
鉴于该版本包含Angular应用程序,因此其中进行了Jasmine测试.我该怎么做才能将那些测试结果作为构建的一部分发布,并且更好的是,在成功执行所有Jasmine测试之后确定构建结果?
Given the build has an Angular app as part of it, there are Jasmine tests in there. What do I have to do to get those test results published as part of the build and better yet, gate the build result on successful execution of all Jasmine tests?
推荐答案
您可以通过以下脚本和任务来做到这一点:
You can do this through the following script and tasks:
在 Azure Pipelines YAML 文件,如下所示:
# perform unit-tets 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
这篇关于作为自动生成过程的一部分,在Azure DevOps上运行Jasmine测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文