lunarmodules / busted

Elegant Lua unit testing.
https://lunarmodules.github.io/busted/
MIT License
1.38k stars 184 forks source link

multiple output options #700

Open hutchic opened 1 year ago

hutchic commented 1 year ago

I want htest output for humans -- to the terminal junit output for computers -- to a file for consumption elsewhere

alerque commented 1 year ago

What exactly is the request here? For an htest output driver? Or did you mean gtest there? Or is the request for simultaneous output to two drivers from one test run?

Tieske commented 1 year ago

htest is an external output library (is on luarocks). So for this request it would be the same as gtest.

The idea is to use two outputs in parallel. To terminal for human consumption, to file for passing results on to a report system or similar

Tieske commented 1 year ago

Passing the events shouldn’t be too hard I think. But how to configure what goes where?

alerque commented 1 year ago

For my use cases the longest running test suite I have with ~500 test units takes a very limited time to run (a few seconds) so I am content running multiple instances of busted for each purpose. Hence I'll be unlikely to work on this directly.

But I'd be happy to facilitate a PR if somebody wants to work on it and contribute a way to do this. In my view it would have to not break existing CLI usage and busted files for people using only one output handler, but within that requirement find some ergonomic way to set it up.

hutchic commented 1 year ago

So the test suite I have is not fast :joy:

Which is why I'd like one output format for humans (htest) and a different output format (junit) to a file for computer consumption

alerque commented 1 year ago

Besides speed it would have the added benefit of CI usage being able to show something to the user in logs but also provide a download artifact with more detailed reports in a more usable format. Even if jobs are fast and for occasional manual trigger it would be tolerable, running everything twice on every invocation by default does get excessive if the output could be captured and handled two ways at once.

myzhan commented 6 months ago

I manage to do this by specify a custom output handler, which combines two output handlers from busted.

return function(options)
    local utfTerminalHandler = require('busted.outputHandlers.utfTerminal')(options)
    utfTerminalHandler:subscribe(options)

    table.insert(options.arguments, 1, "junit.xml")
    local junitHandler = require('busted.outputHandlers.junit')(options)
    junitHandler:subscribe(options)

    return utfTerminalHandler
end