Always write the trivial unit test.
A lot of developers fall out of the habit of writing unit tests, and I definitely understand that pain. I can fall out of the habit, too, and there’s something oddly intimidating about looking at a class and creating a unit test for it. It’s not clear to me what the underlying problem really is: perhaps there just too much to test, and so it is hard to know where to start. Whatever the reason, I find that I can break through that boundary if I just create the test and write:
@Test
public void checkFramework() {
assertTrue(true);
}
Once I get past that point, suddenly the unit tests just flow out of me. But if I don’t get past that point, it’s easy to wander off into cowboy land.
Related posts: