About TestReporter, the documentation says:
In JUnit Jupiter you should use
TestReporterwhere you used to print information tostdoutorstderrin JUnit 4.
This does not clarify the intend behind key value pairs, though, and since leaving them empty is an error, it would help to explain how to use them. Otherwise users might be under the impression that the reporter is only useful to output test data (like in reportSeveralValues in the user guide), but not status messages.
Or maybe add an overload that accepts a single string as a message.
I think key-value pairs should be fine for now.
@nicolaiparlog Do you have time to improve the documentation and send a PR?
I have the time, but not the answer, meaning I don't really know either what you guys had in mind regarding simple status messages. My intuition was to use an empty key and the message as value, but since that doesn't work, I don't really know what to do. :)
Well, as you empirically discovered, one has to supply both key and value. 馃槈
Could you please provide an example for the use case? I think that might help in talking about it.
I will - the next time I want to use the reporter. :wink:
Found one. As a demo for the extension model, I wrote a benchmark extension and it publishes entries like this:
String message = /*...*/;
context.publishReportEntry("Benchmark", message);
Result in IntelliJ:
timestamp = 2018-08-04T09:41:46.305890, Benchmark = Test 'benchmarked()' took 100 ms.
"Benchmark" is a lousy key, but what else could I use? I only really care about the message.
What about adding the following convenience method to ExtensionContext?
default void publishReportMessage(String message) {
this.publishReportEntry("message", message);
}
It'd yield:
timestamp = 2018-08-04T09:41:46.305890, message = Test 'benchmarked()' took 100 ms.
I think the default message key is a good idea.
Great, I'll create a PR later this weekend. :smiley:
Whoa, horsey.... _Immer langsam mit den jungen Pferden_. 馃構
(That's German for "Hold your horses")
j/k... go ahead with the PR. The testing and documentation will take you 20 times longer than implementing (copying-n-pasting) the method. 馃槆
Wow, 20x? It I spent about an hour to prepare the console launcher test input files. That's a quagmire! Otherwise, I think I'm done except for one remaining question - see #1523.
That's a quagmire!
Back fire of the generated/dynamic test feature. :P
Wow, 20x?
Did I say 20x? I meant "at least 2000x". 馃槤
Revised in 1cbda447f499cff7e457790ec67f34c7d5198b8f
Most helpful comment
What about adding the following convenience method to
ExtensionContext?It'd yield:
timestamp = 2018-08-04T09:41:46.305890, message = Test 'benchmarked()' took 100 ms.