There's already a question about How to write good unit tests.
Based on the answers provided there, the key properties of a good unit test -
- Short
- Readable and conveys intent instantly
- Independent
- Fast
- Repeatable
- Tests a single piece of behaviour
- Has a good name
Keeping those properties in mind, how would one go about automating checks for ensuring only "good" unit tests are merged back to the main codebase?
I am absolutely of the opinion that automating these checks is the way to go, if it can be reasonably achieved. There are so many things a reviewer needs to watch out for when accepting a merge request - clean code, design, architecture, clean tests etc. so reducing the burden by automating checks that used to be manual is always welcome.