Unit Testing Anti-Pattern: Code Matching
Sometimes, tests imitate code, and not in a good way. Here’s our tested code: public String encode(String word) { String result = word + word.length(); return result; } And here’s our test: @Test public void howItsDone() { Encoder enc = Read more…
Unit Testing Anti-Pattern: Misleading Tests
You’re testing the right thing, and the test passes, and everything is cool. Or is it? Check out this test: @Test public void encodeString_sizeAtEnd() { Encoder enc = new Encoder(); String result = enc.encode(“hello”); assertEquals(“hello5”, result); } This test looks Read more…
Unit Tests Anti-patterns: TDD without refactoring
Anti-patterns are patterns with negative consequences. In this series I’m going to tackle those patterns, explain what they signify in terms of risks, and what to do instead. Let’s look at a pattern common to people who start out on Read more…