I have a number of JUnit test cases that are currently not documented with Javadoc comments.
The rest of my code is documented, but I'm wondering if it's even worth the effort to document these tests.
The JUnit TestRunners will catch the thrown Exception regardless so you don't have to worry about your entire test suite bailing out if an Exception is thrown. This is the best answer. I'll add that I think the question here is one of style: catch-and-fail, or throw? Normally, best practice avoids "throws Exception".
Once the parallel execution property is set (or enabled), the JUnit Jupiter engine will run the tests in parallel as per the configurations provided with the synchronization mechanisms.
However, despite "unit" being part of its name, JUnit by itself is not limiting you to Unit testing, so it does not impose either a white-box nor a black-box approach. You can use JUnit to do any kind of testing that you like.
If the purpose of the test is obvious, I don't bother documenting it.
If it's non-obvious because it deals with some obscure situation - or if I want to refer to a specific bug, for example - in that case I'll add documentation. I don't document exceptions throw etc though - just a quick summary of the method. This happens relatively rarely. I'm more likely to add documentation for helper methods used within multiple tests.
I don't find any value in javadocing the test cases. I just make the method name descriptive enough to know the purpose of the test.
In Ruby, I know there are tools to create a document from the name of the tests, but I haven't seen one of these in Java.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With