任务PublishTestResults@2找不到我的测试结果文件。为什么不? 我正在使用xmlrunner和 unittest 运行 Python 测试,以生成 JUnit 格式的输出文件。
这是发布任务的相关输出:
2020-01-25T01:12:07.7443604Z ##[debug]pattern: 'testresults/TEST-*.xml'
2020-01-25T01:12:07.7476652Z ##[debug]findPath: './acceptance-tests/OOM-exception/testresults'
2020-01-25T01:12:07.7477167Z ##[debug]statOnly: 'false'
2020-01-25T01:12:07.7478528Z ##[debug]findPath: 'acceptance-tests/OOM-exception/testresults'
2020-01-25T01:12:07.7478992Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T01:12:07.7479362Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T01:12:07.7479710Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T01:12:07.7482715Z ##[debug] acceptance-tests/OOM-exception/testresults (directory)
2020-01-25T01:12:07.7489267Z ##[debug] acceptance-tests/OOM-exception/testresults/TEST-test_OOM_exceptions.OOM_exceptions-20200125011206.xml (file)
2020-01-25T01:12:07.7489642Z ##[debug]2 results
2020-01-25T01:12:07.7490249Z ##[debug]found 2 paths
2020-01-25T01:12:07.7490606Z ##[debug]applying include pattern
2020-01-25T01:12:07.7491144Z ##[debug]adjustedPattern: './acceptance-tests/OOM-exception/testresults/TEST-*.xml'
2020-01-25T01:12:07.7498261Z ##[debug]0 matches
2020-01-25T01:12:07.7504039Z ##[debug]0 final results
2020-01-25T01:12:07.7504342Z ##[debug]Detected 0 test result files
此输出表明测试文件实际上位于正确的位置。我尝试了testResultsFiles
参数的各种变体,包括默认的**/TEST-*.xml
。
顺便说一句,测试本身成功了,并且所有测试实际上都在运行。
这是我的YAML管道中的相关部分:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
- script: python3 -m pip install --upgrade pip setuptools
- script: pip install -r requirements.txt
workingDirectory: '$(testFilesFolder)'
- script: python3 -m xmlrunner discover --output testresults
continueOnError: true
workingDirectory: '$(testFilesFolder)'
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit' # Options: JUnit, NUnit, VSTest, xUnit, cTest
testResultsFiles: 'testresults/TEST-*.xml'
searchFolder: '$(testFilesFolder)'
failTaskOnFailedTests: true
这是任务的完整输出:
2020-01-25T01:12:07.5996494Z ##[debug]Evaluating condition for step: 'PublishTestResults'
2020-01-25T01:12:07.5996980Z ##[debug]Evaluating: SucceededNode()
2020-01-25T01:12:07.5997134Z ##[debug]Evaluating SucceededNode:
2020-01-25T01:12:07.5997333Z ##[debug]=> True
2020-01-25T01:12:07.5997489Z ##[debug]Result: True
2020-01-25T01:12:07.5997666Z ##[section]Starting: PublishTestResults
2020-01-25T01:12:07.6000996Z ==============================================================================
2020-01-25T01:12:07.6001109Z Task : Publish Test Results
2020-01-25T01:12:07.6001211Z Description : Publish test results to Azure Pipelines
2020-01-25T01:12:07.6001273Z Version : 2.162.2
2020-01-25T01:12:07.6001329Z Author : Microsoft Corporation
2020-01-25T01:12:07.6001445Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/test/publish-test-results
2020-01-25T01:12:07.6001514Z ==============================================================================
2020-01-25T01:12:07.7287680Z ##[debug]agent.TempDirectory=/home/vsts/work/_temp
2020-01-25T01:12:07.7311778Z ##[debug]loading inputs and endpoints
2020-01-25T01:12:07.7316458Z ##[debug]loading INPUT_TESTRUNNER
2020-01-25T01:12:07.7326771Z ##[debug]loading INPUT_TESTRESULTSFILES
2020-01-25T01:12:07.7328668Z ##[debug]loading INPUT_SEARCHFOLDER
2020-01-25T01:12:07.7329586Z ##[debug]loading INPUT_MERGETESTRESULTS
2020-01-25T01:12:07.7330846Z ##[debug]loading INPUT_FAILTASKONFAILEDTESTS
2020-01-25T01:12:07.7332115Z ##[debug]loading INPUT_PUBLISHRUNATTACHMENTS
2020-01-25T01:12:07.7332777Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2020-01-25T01:12:07.7334111Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2020-01-25T01:12:07.7334752Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2020-01-25T01:12:07.7339261Z ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
2020-01-25T01:12:07.7340893Z ##[debug]loaded 10
2020-01-25T01:12:07.7358665Z ##[debug]Agent.ProxyUrl=undefined
2020-01-25T01:12:07.7367753Z ##[debug]Agent.CAInfo=undefined
2020-01-25T01:12:07.7368399Z ##[debug]Agent.ClientCert=undefined
2020-01-25T01:12:07.7368766Z ##[debug]Agent.SkipCertValidation=undefined
2020-01-25T01:12:07.7398326Z ##[debug]check path : /home/vsts/work/_tasks/PublishTestResults_0b0f01ed-7dde-43ff-9cbb-e48954daf9b1/2.162.2/task.json
2020-01-25T01:12:07.7398974Z ##[debug]adding resource file: /home/vsts/work/_tasks/PublishTestResults_0b0f01ed-7dde-43ff-9cbb-e48954daf9b1/2.162.2/task.json
2020-01-25T01:12:07.7399510Z ##[debug]system.culture=en-US
2020-01-25T01:12:07.7415772Z ##[debug]testRunner=JUnit
2020-01-25T01:12:07.7421062Z ##[debug]testResultsFiles=testresults/TEST-*.xml
2020-01-25T01:12:07.7422659Z ##[debug]mergeTestResults=false
2020-01-25T01:12:07.7423114Z ##[debug]platform=null
2020-01-25T01:12:07.7423434Z ##[debug]configuration=null
2020-01-25T01:12:07.7423787Z ##[debug]testRunTitle=null
2020-01-25T01:12:07.7424308Z ##[debug]publishRunAttachments=true
2020-01-25T01:12:07.7424851Z ##[debug]failTaskOnFailedTests=true
2020-01-25T01:12:07.7426678Z ##[debug]searchFolder=./acceptance-tests/OOM-exception/
2020-01-25T01:12:07.7427036Z ##[debug]testRunner: JUnit
2020-01-25T01:12:07.7428343Z ##[debug]testResultsFiles: testresults/TEST-*.xml
2020-01-25T01:12:07.7428601Z ##[debug]mergeResults: false
2020-01-25T01:12:07.7428805Z ##[debug]platform: null
2020-01-25T01:12:07.7428998Z ##[debug]config: null
2020-01-25T01:12:07.7429181Z ##[debug]testRunTitle: null
2020-01-25T01:12:07.7429385Z ##[debug]publishRunAttachments: true
2020-01-25T01:12:07.7429576Z ##[debug]failTaskOnFailedTests: true
2020-01-25T01:12:07.7436004Z ##[debug]defaultRoot: './acceptance-tests/OOM-exception/'
2020-01-25T01:12:07.7436605Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T01:12:07.7437018Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T01:12:07.7437421Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T01:12:07.7437851Z ##[debug]matchOptions.debug: 'false'
2020-01-25T01:12:07.7438389Z ##[debug]matchOptions.nobrace: 'true'
2020-01-25T01:12:07.7439173Z ##[debug]matchOptions.noglobstar: 'false'
2020-01-25T01:12:07.7439555Z ##[debug]matchOptions.dot: 'true'
2020-01-25T01:12:07.7440082Z ##[debug]matchOptions.noext: 'false'
2020-01-25T01:12:07.7440915Z ##[debug]matchOptions.nocase: 'false'
2020-01-25T01:12:07.7441403Z ##[debug]matchOptions.nonull: 'false'
2020-01-25T01:12:07.7441842Z ##[debug]matchOptions.matchBase: 'false'
2020-01-25T01:12:07.7442248Z ##[debug]matchOptions.nocomment: 'false'
2020-01-25T01:12:07.7442699Z ##[debug]matchOptions.nonegate: 'false'
2020-01-25T01:12:07.7443144Z ##[debug]matchOptions.flipNegate: 'false'
2020-01-25T01:12:07.7443604Z ##[debug]pattern: 'testresults/TEST-*.xml'
2020-01-25T01:12:07.7476652Z ##[debug]findPath: './acceptance-tests/OOM-exception/testresults'
2020-01-25T01:12:07.7477167Z ##[debug]statOnly: 'false'
2020-01-25T01:12:07.7478528Z ##[debug]findPath: 'acceptance-tests/OOM-exception/testresults'
2020-01-25T01:12:07.7478992Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T01:12:07.7479362Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T01:12:07.7479710Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T01:12:07.7482715Z ##[debug] acceptance-tests/OOM-exception/testresults (directory)
2020-01-25T01:12:07.7489267Z ##[debug] acceptance-tests/OOM-exception/testresults/TEST-test_OOM_exceptions.OOM_exceptions-20200125011206.xml (file)
2020-01-25T01:12:07.7489642Z ##[debug]2 results
2020-01-25T01:12:07.7490249Z ##[debug]found 2 paths
2020-01-25T01:12:07.7490606Z ##[debug]applying include pattern
2020-01-25T01:12:07.7491144Z ##[debug]adjustedPattern: './acceptance-tests/OOM-exception/testresults/TEST-*.xml'
2020-01-25T01:12:07.7498261Z ##[debug]0 matches
2020-01-25T01:12:07.7504039Z ##[debug]0 final results
2020-01-25T01:12:07.7504342Z ##[debug]Detected 0 test result files
2020-01-25T01:12:07.7507804Z ##[debug]which 'dotnet'
2020-01-25T01:12:07.7513265Z ##[debug]found: '/usr/bin/dotnet'
2020-01-25T01:12:07.7515323Z ##[debug]which '/usr/bin/dotnet'
2020-01-25T01:12:07.7515798Z ##[debug]found: '/usr/bin/dotnet'
2020-01-25T01:12:07.7516162Z ##[debug]which '/usr/bin/dotnet'
2020-01-25T01:12:07.7516568Z ##[debug]found: '/usr/bin/dotnet'
2020-01-25T01:12:07.7518901Z ##[debug]/usr/bin/dotnet arg: --version
2020-01-25T01:12:07.7523251Z ##[debug]exec tool: /usr/bin/dotnet
2020-01-25T01:12:07.7523631Z ##[debug]arguments:
2020-01-25T01:12:07.7524431Z ##[debug] --version
2020-01-25T01:12:07.7528296Z [command]/usr/bin/dotnet --version
2020-01-25T01:12:11.2588747Z 3.0.101
2020-01-25T01:12:11.2655417Z ##[warning]No test result files matching testresults/TEST-*.xml were found.
2020-01-25T01:12:11.2666650Z ##[debug]Processed: ##vso[task.issue type=warning;]No test result files matching testresults/TEST-*.xml were found.
2020-01-25T01:12:11.2666885Z ##[debug]task result: Succeeded
2020-01-25T01:12:11.2667398Z ##[debug]Processed: ##vso[task.complete result=Succeeded;]
2020-01-25T01:12:11.2667534Z ##[debug]Release.ReleaseUri=undefined
2020-01-25T01:12:11.2667651Z ##[debug]Release.ReleaseId=undefined
2020-01-25T01:12:11.2667757Z ##[debug]Build.BuildUri=vstfs:///Build/Build/80106
2020-01-25T01:12:11.2667875Z ##[debug]Build.Buildid=80106
2020-01-25T01:12:11.3132563Z ##[debug]Processed: ##vso[telemetry.publish area=TestExecution;feature=PublishTestResultsTask]{"builduri":"vstfs:///Build/Build/80106","buildid":"80106","osType":"Linux","testRunner":"JUnit","failTaskOnFailedTests":"true","mergeResultsUserPreference":"false","config":null,"platform":null,"testResultsFilesCount":0,"dotnetVersion":"3.0.101","noResultsFileFound":true,"subFeature":"publishTestResultsTaskConsolidatedCiEvent"}
2020-01-25T01:12:11.3134445Z ##[section]Finishing: PublishTestResults
编辑: 尝试了jessehouwing的答案。这没有帮助。这些是日志:
2020-01-25T15:45:20.0576358Z ##[debug]searchFolder=./acceptance-tests/OOM-exception/
2020-01-25T15:45:20.0576743Z ##[debug]testRunner: JUnit
2020-01-25T15:45:20.0577183Z ##[debug]testResultsFiles: TEST-*.xml
2020-01-25T15:45:20.0577305Z ##[debug]mergeResults: false
2020-01-25T15:45:20.0577462Z ##[debug]platform: null
2020-01-25T15:45:20.0577563Z ##[debug]config: null
2020-01-25T15:45:20.0577706Z ##[debug]testRunTitle: null
2020-01-25T15:45:20.0577851Z ##[debug]publishRunAttachments: true
2020-01-25T15:45:20.0577958Z ##[debug]failTaskOnFailedTests: true
2020-01-25T15:45:20.0583685Z ##[debug]defaultRoot: './acceptance-tests/OOM-exception/'
2020-01-25T15:45:20.0584023Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T15:45:20.0586845Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T15:45:20.0587255Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T15:45:20.0587596Z ##[debug]matchOptions.debug: 'false'
2020-01-25T15:45:20.0587832Z ##[debug]matchOptions.nobrace: 'true'
2020-01-25T15:45:20.0588932Z ##[debug]matchOptions.noglobstar: 'false'
2020-01-25T15:45:20.0589501Z ##[debug]matchOptions.dot: 'true'
2020-01-25T15:45:20.0589789Z ##[debug]matchOptions.noext: 'false'
2020-01-25T15:45:20.0590176Z ##[debug]matchOptions.nocase: 'false'
2020-01-25T15:45:20.0590421Z ##[debug]matchOptions.nonull: 'false'
2020-01-25T15:45:20.0590685Z ##[debug]matchOptions.matchBase: 'false'
2020-01-25T15:45:20.0590905Z ##[debug]matchOptions.nocomment: 'false'
2020-01-25T15:45:20.0591171Z ##[debug]matchOptions.nonegate: 'false'
2020-01-25T15:45:20.0591432Z ##[debug]matchOptions.flipNegate: 'false'
2020-01-25T15:45:20.0591690Z ##[debug]pattern: 'TEST-*.xml'
2020-01-25T15:45:20.0631976Z ##[debug]findPath: './acceptance-tests/OOM-exception'
2020-01-25T15:45:20.0632431Z ##[debug]statOnly: 'false'
2020-01-25T15:45:20.0632752Z ##[debug]findPath: 'acceptance-tests/OOM-exception'
2020-01-25T15:45:20.0633054Z ##[debug]findOptions.allowBrokenSymbolicLinks: 'true'
2020-01-25T15:45:20.0633332Z ##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
2020-01-25T15:45:20.0634538Z ##[debug]findOptions.followSymbolicLinks: 'true'
2020-01-25T15:45:20.0634974Z ##[debug] acceptance-tests/OOM-exception (directory)
2020-01-25T15:45:20.0646126Z ##[debug] acceptance-tests/OOM-exception/.dockerignore (file)
2020-01-25T15:45:20.0646726Z ##[debug] acceptance-tests/OOM-exception/.vscode (directory)
2020-01-25T15:45:20.0654441Z ##[debug] acceptance-tests/OOM-exception/.vscode/settings.json (file)
2020-01-25T15:45:20.0655814Z ##[debug] acceptance-tests/OOM-exception/CI (directory)
2020-01-25T15:45:20.0656184Z ##[debug] acceptance-tests/OOM-exception/CI/azure-test-OOM-exception-pipeline.yml (file)
2020-01-25T15:45:20.0657679Z ##[debug] acceptance-tests/OOM-exception/CI/config-ubuntu1804.sh (file)
2020-01-25T15:45:20.0661849Z ##[debug] acceptance-tests/OOM-exception/CI/config-windowsserver2019.ps1 (file)
2020-01-25T15:45:20.0662326Z ##[debug] acceptance-tests/OOM-exception/CI/test-VM-ARM-template-param.json (file)
2020-01-25T15:45:20.0662984Z ##[debug] acceptance-tests/OOM-exception/CI/test-VM-ARM-template.json (file)
2020-01-25T15:45:20.0665752Z ##[debug] acceptance-tests/OOM-exception/__pycache__ (directory)
2020-01-25T15:45:20.0666188Z ##[debug] acceptance-tests/OOM-exception/__pycache__/test_OOM_exceptions.cpython-38.pyc (file)
2020-01-25T15:45:20.0666991Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent (directory)
2020-01-25T15:45:20.0667347Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/.vscode (directory)
2020-01-25T15:45:20.0667600Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/.vscode/settings.json (file)
2020-01-25T15:45:20.0668189Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/acceptance-test-agent.py (file)
2020-01-25T15:45:20.0668538Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/command_json_schema.json (file)
2020-01-25T15:45:20.0668786Z ##[debug] acceptance-tests/OOM-exception/acceptance_test_agent/requirements.txt (file)
2020-01-25T15:45:20.0669073Z ##[debug] acceptance-tests/OOM-exception/dc-authenticatieservice.Dockerfile (file)
2020-01-25T15:45:20.0669375Z ##[debug] acceptance-tests/OOM-exception/dc-dsbestellingbeheer.Dockerfile (file)
2020-01-25T15:45:20.0669614Z ##[debug] acceptance-tests/OOM-exception/dc-dsklantbeheer.Dockerfile (file)
2020-01-25T15:45:20.0669916Z ##[debug] acceptance-tests/OOM-exception/dc-frontend.Dockerfile (file)
2020-01-25T15:45:20.0670189Z ##[debug] acceptance-tests/OOM-exception/dc-spa.Dockerfile (file)
2020-01-25T15:45:20.0670429Z ##[debug] acceptance-tests/OOM-exception/docker-compose.override-images.yml (file)
2020-01-25T15:45:20.0670712Z ##[debug] acceptance-tests/OOM-exception/docker-compose.yml (file)
2020-01-25T15:45:20.0670990Z ##[debug] acceptance-tests/OOM-exception/docker_entry_point_sql-datacycle.sh (file)
2020-01-25T15:45:20.0671379Z ##[debug] acceptance-tests/OOM-exception/kantilever-datacycle-eventbus.Dockerfile (file)
2020-01-25T15:45:20.0671646Z ##[debug] acceptance-tests/OOM-exception/requirements.txt (file)
2020-01-25T15:45:20.0672447Z ##[debug] acceptance-tests/OOM-exception/runTest.sh (file)
2020-01-25T15:45:20.0672689Z ##[debug] acceptance-tests/OOM-exception/sql-datacycle.Dockerfile (file)
2020-01-25T15:45:20.0673143Z ##[debug] acceptance-tests/OOM-exception/test_OOM_exceptions.py (file)
2020-01-25T15:45:20.0673465Z ##[debug] acceptance-tests/OOM-exception/testresults (directory)
2020-01-25T15:45:20.0673717Z ##[debug] acceptance-tests/OOM-exception/testresults/TEST-test_OOM_exceptions.OOM_exceptions-20200125154519.xml (file)
2020-01-25T15:45:20.0673883Z ##[debug]33 results
2020-01-25T15:45:20.0674025Z ##[debug]found 33 paths
2020-01-25T15:45:20.0674129Z ##[debug]applying include pattern
2020-01-25T15:45:20.0674514Z ##[debug]adjustedPattern: './acceptance-tests/OOM-exception/TEST-*.xml'
2020-01-25T15:45:20.0678453Z ##[debug]0 matches
2020-01-25T15:45:20.0686188Z ##[debug]0 final results
2020-01-25T15:45:20.0687625Z ##[debug]Detected 0 test result files
答案 0 :(得分:0)
我使用xmlrunner进行了测试,并通过发布测试结果任务发布了测试结果。工作正常。
上述错误表明No test result files matching testresults/TEST-*.xml were found.
yaml管道中定义的$(testFilesFolder)
变量可能是错误的。您可以尝试使用predefined variables(例如$(system.defaultworkingdirectory)/acceptance-tests/OOM-exception
)指向代理上的位置。
下面是我的测试项目结构:
下面是我的Yaml管道:
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
displayName: 'Use Python 3.8'
- script: |
python3 -m pip install --upgrade pip
pip install -r requirements.txt
displayName: 'Install dependencies'
- script: |
python3 -m xmlrunner discover --output testresults
continueOnError: true
workingDirectory: '$(system.defaultworkingdirectory)/acceptancetest/testfolder'
displayName: 'pytest'
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: 'testresults/TEST-*.xml'
searchFolder: '$(system.defaultworkingdirectory)/acceptancetest/testfolder'
failTaskOnFailedTests: true