3 ms·
I think this was only a poor example because the method under test was a "director" style method (not sure what the name of it would actually be) that simply fo
by lectrick 13y ago
I think this was only a poor example because the method under test was a "director" style method (not sure what the name of it would actually be) that simply forwards a bunch of messages/commands to other objects and doesn't do much actual logic/computation.
Tests for these "director" style methods must by nature assert that all the right messages were forwarded to the right objects under the right circumstances, so yes, you do end up with tests that look a lot like what they're testing.
Agreed that ideally you are only testing ins and outs though, but I think this case was exceptional.
- pkolaczk 13y agoIt is better to not have a test at all than to have a test that looks a lot like what it is testing. I never uderstood that crazy push for 100% unit test coverage that some are advocating. Unit tests are just one tool among many. Use with care and where appropriate.
- regularfry 13y agoI think this is actually an argument that the tests are telling us that having a controller class this shape isn't the design we should aim for.