如何让PDK test unit同时输出JUnit报告至文件及测试结果至控制台?
I totally get the frustration—having to dig into a JUnit report file just to see why tests failed is a real workflow killer. Good news is PDK supports multiple output formats in a single command, so you can keep the Jenkins-friendly JUnit report and get immediate console output for your devs.
Here's how to adjust your command:
Step 1: Update the PDK Test Command
Instead of specifying just the JUnit format, add a console-friendly format alongside it using multiple --format flags (comma-separated values also work in most PDK versions):
Option 1: Use Progress Format (Concise, Default Style)
This gives you the same compact progress output you'd get without any format flags, plus the JUnit report:
pdk test unit --format=progress --format=junit:report.xml
Option 2: Use Documentation Format (Detailed Test Output)
If your devs want full visibility into each test's pass/fail status right in the console (great for debugging failures quickly), use the documentation format instead:
pdk test unit --format=documentation --format=junit:report.xml
Why This Works
When you only specify --format=junit:report.xml, PDK redirects all test output exclusively to the XML file. By adding a console-focused format, you tell PDK to send output to both the console and the JUnit file simultaneously.
Verify It Works
Run the updated command locally first to confirm:
- You'll see test results streaming in the console (either progress bars or full test details)
- The
report.xmlfile will still be generated with all the structured data Jenkins needs for its test dashboard
内容的提问来源于stack exchange,提问作者Michael P.

