...read all 25 words  out loud: RED, GREEN, BLUE, ...  (Try it now!)  ...say all 25 colors  out loud: GREEN, YELLOW, WHITE... (Try it now!)   Stroop Effect , which roughly says that when a label  (in this case, the word) is in the same domain as its content  (the color) with a conflicting meaning, the label interferes with your ability to comprehend the content.public void testProtanopiaColorMatcherIsDistinguishable() {   ColorMatcher colorMatcher = new ColorMatcher(PROTANOPIA);   assertFalse(“BLUE and VIOLET are indistinguishable”,      colorMatcher.isDistinguishable(Color.BLUE, Color.VIOLET));  } 
Failure: testProtanopiaColorMatcherIsDistinguishable: Message: BLUE and VIOLET are indistinguishable 
label  (the message) expresses a truth condition, but the content  (in assertFalse Failure: testProtanopiaColorMatcherCannotDistinguishBetweenCertainPairsOfColors Message: BLUE and VIOLET should be indistinguishable 
should  have been indistinguishable, but weren't . When someone breaks your test – will your test name and message be useful to them? Opinionated test names like testMethodDoesSomething testMethod  Great test messages not only identify the actual behavior,but also the expected behavior. Should  is a handy word to use in messages – it clarifies what expected  behavior didn't actually  happen.
 
 
 
I'm programming in Ruby on Rails and my most common error message (errors cause most test failures in my app) is "You have a nil object where you didn't expect it"
ReplyDeleteHi. I posted a comment here: http://www.googcomments.blogspot.com
ReplyDelete