Something more interesting to think about is how much information a test gives you that your code works.
There are several tools that help to increase that amount, that test your tests in other words. They’re far from conclusive or thorough, but they can help a great deal:
Coverage testers: This technique involves running your tests and seeing which lines in your program they involve, or (for more sophisticated versions of this technique) which possible paths through your program are ran. If you have full coverage that’s no guarantee that you have thorough tests… but if you have low coverage that definitely means your tests could be improved, because there are parts of your program that aren’t being tested.
Mutation testers: These tools will randomly introduce temporary but destructive changes in your code (swapping strings for nonsense, flipping booleans, and so on), and then run the unit tests to make sure they fail. This is far from rigorous, but it can be useful; if your test is passing even though your code isn’t actually working, then that means there’s an opportunity for a bug to be introduced there without being detected.
(Darmani, you probably already know all this; I’m saying it for whoever else might be reading this discussion.)
There are several tools that help to increase that amount, that test your tests in other words. They’re far from conclusive or thorough, but they can help a great deal:
Coverage testers: This technique involves running your tests and seeing which lines in your program they involve, or (for more sophisticated versions of this technique) which possible paths through your program are ran. If you have full coverage that’s no guarantee that you have thorough tests… but if you have low coverage that definitely means your tests could be improved, because there are parts of your program that aren’t being tested.
Mutation testers: These tools will randomly introduce temporary but destructive changes in your code (swapping strings for nonsense, flipping booleans, and so on), and then run the unit tests to make sure they fail. This is far from rigorous, but it can be useful; if your test is passing even though your code isn’t actually working, then that means there’s an opportunity for a bug to be introduced there without being detected.
(Darmani, you probably already know all this; I’m saying it for whoever else might be reading this discussion.)