|
|
|
|
|
by nfrbc
2519 days ago
|
|
I completely agree with the code coverage part. A previous codebase I worked in was terrible to refactor because of the insane amount of tautological unit tests and abuse of mocking. For new features we stopped writing tests that were too specific and started writing more integration tests. We achieved a leap in quality and ease of development. |
|
1. cross multiple boundaries (integration test) by asserting that some system two degrees away from itself is being run/invoked (not a unit test's duty)
2. test descriptions read along the lines of, "it should work for valid use cases". This one made me laugh when I first saw it. This made refactoring a HUGE undertaking as I had to comb through all of it to understand it
3. mocking systems that weren't created by "us" -- this resulted in blind spots in various places
Test/code coverage is only one of many metrics to consider. I think it's useful, but its utility heavily relies on the quality of tests that are written.
I'm beginning to think that a hallmark of a good developer is one that understand what tests need to be written and what assertions must be made. This shines when the tests are written such that the developer can see how API design affects testing. I've worked in both functional and imperative languages and FP testing is harder to screw up as it forces the use of dependency injection. The idea of DI and inserting role players in imperative langs makes testing easier and shows that someone has thought about a reliance on behavior rather than concretions. So when I interview people, I always ask about dependency injection and polymorphism.
But working with seemingly more experienced (on paper) than me, I know that experience is also a terrible metric to rely on.