在 Python 中发布单元测试
Publish Unit test in Python
我需要发布结果,但不能并且已经浏览了这个网站并进行了研究,但仍然无法发布测试结果。我是否需要编辑类似于 cypress.json 的某些文件才能解决发布问题。单元测试和覆盖率都没有发布任何结果,也没有找到文件。下面突出显示了代码以及有错误的结果。
代码:
trigger:
branches:
include:
- #infra-ML-unit-test
variables:
- group: aws_details #just for backup roles approach
- group: snowflake-variables
- group: unit-test-dev
jobs:
- job: 'Unit_Test'
pool:
vmImage: 'windows-latest' # other options: 'macOS-latest', 'windows-latest', 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
displayName: 'Use Python 3.x'
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
- script: |
pip install virtualenv
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
python -m pip install --upgrade pip setuptools sqlalchemy snowflake.sqlalchemy
echo "$(System.DefaultWorkingDirectory)"
echo "$(Build.StagingDirectory)"
pip show pandas
python -m pytest --log-file $SYSTEM_ARTIFACTSDIRECTORY/smoke-qa.log --junitxml=TEST-qa-smoke.xml -rP --excelreport=report.xls --html=pytest_report.html --self-contained-html
#displayName: 'Install python tools'
- job: publish_result
dependsOn: Unit_Test
condition: succeededOrFailed()
steps:
- task: PublishTestResults@2
displayName: 'Publish test result /010.xml'
inputs:
testResultsFormat: 'JUnit' # Options: JUnit, NUnit, VSTest, xUnit, cTest
testResultsFiles: '**/TEST-*.xml'
testRunTitle: 010
mergeTestResults: true
Pytest 结果
单元测试和覆盖率
是否有任何文件可以在存储库中找到要更新和link发布覆盖和测试结果,因为提到错误或警告:
**
##[warning]No test result files matching /TEST-*.xml were found.
**
您有两个选择:
- 在 运行 测试之前安装 pytest-azurepipelines 包:
pip install pytest pytest-azurepipelines
使 PublishTestResults@2
任务从 $(Pipeline.Workspace)
:
开始搜索
- task: PublishTestResults@2
displayName: 'Publish test result /010.xml'
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '$(Pipeline.Workspace)/junit/test-*.xml'
有关详细信息,请参阅 Python: Run tests
我需要发布结果,但不能并且已经浏览了这个网站并进行了研究,但仍然无法发布测试结果。我是否需要编辑类似于 cypress.json 的某些文件才能解决发布问题。单元测试和覆盖率都没有发布任何结果,也没有找到文件。下面突出显示了代码以及有错误的结果。
代码:
trigger:
branches:
include:
- #infra-ML-unit-test
variables:
- group: aws_details #just for backup roles approach
- group: snowflake-variables
- group: unit-test-dev
jobs:
- job: 'Unit_Test'
pool:
vmImage: 'windows-latest' # other options: 'macOS-latest', 'windows-latest', 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
displayName: 'Use Python 3.x'
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
- script: |
pip install virtualenv
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
python -m pip install --upgrade pip setuptools sqlalchemy snowflake.sqlalchemy
echo "$(System.DefaultWorkingDirectory)"
echo "$(Build.StagingDirectory)"
pip show pandas
python -m pytest --log-file $SYSTEM_ARTIFACTSDIRECTORY/smoke-qa.log --junitxml=TEST-qa-smoke.xml -rP --excelreport=report.xls --html=pytest_report.html --self-contained-html
#displayName: 'Install python tools'
- job: publish_result
dependsOn: Unit_Test
condition: succeededOrFailed()
steps:
- task: PublishTestResults@2
displayName: 'Publish test result /010.xml'
inputs:
testResultsFormat: 'JUnit' # Options: JUnit, NUnit, VSTest, xUnit, cTest
testResultsFiles: '**/TEST-*.xml'
testRunTitle: 010
mergeTestResults: true
Pytest 结果
单元测试和覆盖率
是否有任何文件可以在存储库中找到要更新和link发布覆盖和测试结果,因为提到错误或警告:
**
##[warning]No test result files matching /TEST-*.xml were found.
**
您有两个选择:
- 在 运行 测试之前安装 pytest-azurepipelines 包:
pip install pytest pytest-azurepipelines
使
开始搜索PublishTestResults@2
任务从$(Pipeline.Workspace)
:- task: PublishTestResults@2 displayName: 'Publish test result /010.xml' inputs: testResultsFormat: 'JUnit' testResultsFiles: '$(Pipeline.Workspace)/junit/test-*.xml'
有关详细信息,请参阅 Python: Run tests