How do you unit test a unit test? [closed]

First, testing is like security — you can never be 100% sure you’ve got it, but each layer adds more confidence and a framework for more easily fixing the problems that remain.

Second, you can break tests into subroutines which themselves can then be tested. When you have 20 similar tests, making a (tested) subroutine means your main test is 20 simple invocations of the subroutine which is much more likely to be correct.

Third, some would argue that TDD addresses this concern. That is, if you just write 20 tests and they pass, you’re not completely confident that they are actually testing anything. But if each test you wrote initially failed, and then you fixed it, then you’re much more confident that it’s really testing your code. IMHO this back-and-forth takes more time than it’s worth, but it is a process that tries to address your concern.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)