lehmannro / assert.sh

bash unit testing framework
GNU Lesser General Public License v3.0
487 stars 57 forks source link

Generate JUnit XML #18

Open cadorn opened 8 years ago

cadorn commented 8 years ago

Would be awesome to optionally get a JUnit XML test report at the end.

Any suggestions as to how that could best be accomplished?

lehmannro commented 8 years ago

I'm hesitant to add this to the core because I expect it to be a rather large change.

I think technically the easiest way would be a layer on top of assert.sh which prints the header boilerplate (<junit>) at sourcing time and the footer at exit (_assert_cleanup). Test suite markup can be printed at each assert_end which has all reports in $tests_errors.

(If you wanted to retain function names, you could do something like eval $(typedef -f assert_end | sed '1s/.*/orig_&/') and call orig_assert_end from your custom assert_end.)

If you need any API guarantees for this to work seamlessly I'm happy to oblige; I won't find the time to implement the JUnit XML output myself though.