The Daily WTF
Rick was recently looking at some code from another team at his company. He noticed something odd in the code, so he pinged the team lead, Linda. “Did you spot this?”
“Oh, crap no,” Linda replied. “I should have caught this in code review, but I gotta be honest, Teddy is a bit… well, let’s just say I really should have caught that since I knew it was a Teddy commit.”
Rick didn’t know much about Teddy, beside the fact that Teddy had a few years of experience. Certainly, he had enough experience to be familiar with Java programming, like working with enums and working with unit tests. Unfortunately, he doesn’t seem to understand them.
public class ProductCodeEnumTest { @Test public void testProductCodeEnum_ProductCodeEnumExists() { String[] actualResults = {“PRODUCT_CODE_A”,”PRODUCT_CODE_B”}; ProductCodeEnum[] expectedResults = ProductCodeEnum.values(); for (int i=0; i<actualResults.length; i++) { assertEquals(“Expected results do not equal actual results.”, expectedResults[i].getValue(), actualResults[i]); } } }
To read the full article click on the 'post' link at the top.