lunarmodules / busted

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

opt: junit support split out; optimize display format #734

Closed yeshan333 closed 6 months ago

yeshan333 commented 6 months ago

Features:

Optimizations:

After optimizations:

Reproduction demo: https://github.com/yeshan333/busted_junit_demo

alerque commented 6 months ago

Are there any junit consumers that would not benefit from this? As in, is there an argument for this being the default?

yeshan333 commented 6 months ago

Are there any junit consumers that would not benefit from this? As in, is there an argument for this being the default? @alerque

This is very useful for users who use web UI to view test reports in CI System(eg:Jenkins. Junit is one of the most widely used testing frameworks in the Java ecosystem, while Jenkins is the most widely used automation system in the Java ecosystem.), But this will not have any impact on users who enjoy using terminals to view results.

Java's classes use (.) De-district the hierarchical structure of the project.

The original implementation resulted in an ugly use case hierarchy for CI splitting.

the element.trace.short_src are usually forms such as case_spec.lua. This means that lua has been recognized as a class in the Java ecosystem.

https://github.com/lunarmodules/busted/blob/02f31a9c103a44e166617cfdb6ba1b8994a9c912/busted/outputHandlers/junit.lua#L106

For outputting test cases in the suiteEnd stage, when the scale of test cases is very large, it is convenient to view some results in real time (perhaps you may ask: is it not good to directly specify the execution of a certain test case, but for projects where some test cases will affect each other, this helps to identify problem cases or test small earlier) For outputting test cases in the xx stage, when the scale of test cases is very large, it is considered to view some results in real time (per hats you may ask, it is not good to directly specify the execution of a certain test case, but for projects where some test cases will affect each other, this helps to identify problem cases or find test smells problems earlier)

alerque commented 6 months ago

Yes I get how this improves output for web UIs setup for Java, my question was about whether the output would be worse anywhere else if we made it the default. Is junit ever useful on a terminal for example? Or would folks normally be using other outputters there anyway?

yeshan333 commented 6 months ago

Yes I get how this improves output for web UIs setup for Java, my question was about whether the output would be worse anywhere else if we made it the default. Is junit ever useful on a terminal for example? Or would folks normally be using other outputters there anyway? @alerque

The impact is minimal. The junit terminal output works well. I have some tests on Github Actions and Gitlab CI, you can take a look: