1

We have introduced the PDK lately into our developments chain and are now trying to make everybody happy with the test outputs it generates.

We need an output as JUnit test report for our jenkins jobs. That we have solved.

And we need the output still on the console because some of the developers find it very annoying having to open the JUnit report file before they can see failed tests.

pdk test unit --format=junit:report.xml

Is how we configured the output for JUnit.

Unfortunately as soon as you configure the JUnit report no output gets printed on the console/stdout anymore. Even if you add another format like --format=text without target file.

Is there a way to achieve both without running the PDK twice?

Michael P.
  • 33
  • 6

2 Answers2

3

It doesn't appear to be in the docs, but this should work.

pdk test unit --format=junit:report.xml --format=text:stdout 

See https://github.com/puppetlabs/pdk/blob/7b2950bc5fb2e88ead7321c82414459540949eb1/lib/pdk/cli/util/option_normalizer.rb#L10-L24

I've filed a ticket to ensure that gets promoted to the docs at https://puppet.com/docs/pdk/1.x/pdk_reference.html#pdk-test-unit-command

binford2k
  • 46
  • 3
0

From PDK documentation

--format=[:]

Specifies the format of the output. Optionally, you can specify a target file for the given output format, such as --format=junit:report.xml . Multiple --format options can be specified as long as they all have distinct output targets

So I believe ,you can try as below

pdk test unit --tests=testcase_name --format=junit:report.xml --format=text:log.txt

Hope it helps.

Raja G
  • 5,973
  • 14
  • 49
  • 82
  • This will not print the output to the console but to two files. The goal is to have one output like --format=junit:report.xml and one going directly to stdout. But as soon as you have one output configured going to file, nothing comes up on stdout anymore. – Michael P. Apr 16 '18 at 06:53