Running Jasmine tests on Azure DevOps as part of a

2020-08-01 07:45发布

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?

1条回答
我只想做你的唯一
2楼-- · 2020-08-01 08:06

You can do this through the following script and tasks:

  1. run ng test
  2. publish test results with PublishTestResults task
  3. publish code coverage results with PublishCodeCoverageResults task

In the Azure Pipelines YAML file, this could look as follows:

# 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     
查看更多
登录 后发表回答