When using the PublishTestResults step in a YAML pipeline it's quite difficult to find the right syntax for specifying multiple files and using an exclude. We tried semicolons, commas and files with quotes.
We found this syntax worked:
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Thank you for your feedback. I have passed this on to the product team for advice and I will update the topic to include their recommendation.
@chappers00 @alexhomer1 can you confirm the separator for multiple files? @alexhomer1 as this isn't possible to do via the azure pipeline build definition (web portal)
@akinsolb below was the syntax which worked for me, essentially a combination of the pipe symbol and new lines for each pattern:
I can confirm this is still existing. The following ways did not work:
- task: PublishTestResults@2
displayName: Publish Test Results **/test-*.xml
inputs:
testResultsFiles: '**/test-*.xml;**/junit.xml'
failTaskOnFailedTests: 'true'
- task: PublishTestResults@2
displayName: Publish Test Results **/test-*.xml
inputs:
testResultsFiles: |-
'**/test-*.xml'
'**/junit.xml'
failTaskOnFailedTests: 'true'
- task: PublishTestResults@2
displayName: Publish Test Results **/test-*.xml
inputs:
testResultsFiles: |
'**/test-*.xml'
failTaskOnFailedTests: 'true'
In any of the above ways, my build failed to recognize any test results
The only way that worked was when I had testResultsFiles with a pipe, and each item defined without any quotes (almost like quotes were being treated as part of the path). My VSCode seems angry at this format, but it works:
- task: PublishTestResults@2
displayName: Publish Test Results **/test-*.xml
inputs:
testResultsFiles: |
**/test-*.xml
**/junit.xml
failTaskOnFailedTests: 'true'
For multiple values you multi-line values without quotes will work. Use quotes only for single values.
I shall add an example in the doc as well so to avoid confusion.
@Additi - can you look into this?
The fix suggested by @AjkayAlan above does not work for me. I am trying to publish **/surefire-reports/TEST-*.xml and **/failsafe-reports/TEST-*.xml but without success. @divais - where can I find the updated documentation?
@larsWH the document is not yet updated. I'll get them updated and share the link.
This is working for me:
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: |
**/surefire-reports/TEST-*.xml
**/failsafe-reports/TEST-*.xml
goals: 'package'
codeCoverageToolOption: 'jaCoCo'
- task: PublishTestResults@2
displayName: Publish Test Results **/test-*.xml
inputs:
testResultsFiles: |
**/surefire-reports/TEST-*.xml
**/failsafe-reports/TEST-*.xml
failTaskOnFailedTests: true
Just to add, the documentation hasn't been updated yet. Documentation states you should separate with a semicolon.
The above method worked for me with the pipe and multiple lines, no quotes.
This issue hasn't been updated in more than 180 days, so we've closed it. If you feel the issue is still relevant and needs fixed, please reopen it and we'll take another look. We appreciate your feedback and apologize for any inconvenience.
Adding @shashban
Most helpful comment
I can confirm this is still existing. The following ways did not work:
In any of the above ways, my build failed to recognize any test results
The only way that worked was when I had testResultsFiles with a pipe, and each item defined without any quotes (almost like quotes were being treated as part of the path). My VSCode seems angry at this format, but it works: