Skip to content

Commit 5073159

Browse files
authored
Merge pull request #24 from Microsoft/azure-pipelines-pytest
Publish unit test results and code coverage
2 parents bc6b0fc + c833f42 commit 5073159

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.
165165
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
166166

167167
## Unit tests
168-
Run unit tests from the project root by running:
168+
Run unit tests from the project root either with the built-in `unittest` module:
169169

170170
python -m unittest discover
171+
172+
Or by using `pytests`, which can produce reports both for unit test success and for code coverage, by
173+
using the following invocation:
174+
175+
pip install pytest
176+
pip install pytest-cov
177+
pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=callgraph --cov-report=xml --cov-report=html

azure-pipelines.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,24 @@ jobs:
2929
versionSpec: '$(python.version)'
3030
architecture: 'x64'
3131

32-
- script: python -m unittest discover
32+
- script: |
33+
pip install pytest
34+
pip install pytest-cov
35+
pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=callgraph --cov-report=xml --cov-report=html
3336
displayName: 'Unit Tests'
3437
38+
- task: PublishTestResults@2
39+
condition: succeededOrFailed()
40+
inputs:
41+
testResultsFiles: '**/test-*.xml'
42+
testRunTitle: 'Publish test results for Python $(python.version)'
43+
44+
- task: PublishCodeCoverageResults@1
45+
inputs:
46+
codeCoverageTool: Cobertura
47+
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
48+
reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov'
49+
3550
- job: 'GenerateSamples'
3651
dependsOn: 'Test'
3752
pool:

0 commit comments

Comments
 (0)