Postmortem: Template unittests are bad & you shouldn't catch Error

Dukc ajieskola at gmail.com
Fri Oct 23 15:56:05 UTC 2020


On Thursday, 22 October 2020 at 20:54:52 UTC, H. S. Teoh wrote:
>
> I agree tests are watchers.  But it starts a bit ridiculous 
> when you need to test your tests...
>

It might not be.

In my opinion, the answer to "who watches the watchmen?" is "a 
manual test". If you automate a test, you should test the test 
yourself. If you automate testing the test, you should test the 
test-tester and so on.

What is the point then in unit tests? I believe it is in reducing 
the amount of manual testing. You will not have to change a good 
unit test nearly as often as you have to change the code it is 
testing. If it does not change, it does not need rechecking.

The assertions within the function usually don't share this 
property. They may rely on the internal logic of the function, 
and thus get changed with it. Manually testing them sucks just as 
much as relying on manual tests in general. Contracts might be 
better in this regard though, as long as the function is either 
public or widely used internally, so that it's interface and 
intended functionality don't change often.


More information about the Digitalmars-d mailing list