The Artima Developer Community
Sponsored Link

Java Buzz Forum
Who tests the tests?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Simon Brown

Posts: 636
Nickname: simonbrown
Registered: Jun, 2003

Simon Brown is a Java developer, architect and author.
Who tests the tests? Posted: May 25, 2006 2:50 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Simon Brown.
Original Post: Who tests the tests?
Feed Title: Simon Brown's weblog
Feed URL: http://www.simongbrown.com/blog/feed.xml?flavor=rss20&category=java
Feed Description: My thoughts on Java, software development and technology.
Latest Java Buzz Posts
Latest Java Buzz Posts by Simon Brown
Latest Posts From Simon Brown's weblog

Advertisement

Being a blogging application, Pebble is quite date/time sensitive, particularly when it comes to generating things such as permalinks. Much of the code has been running without problem for a long time now (did you know that Pebble was started 3 years ago?) and I have a fairly decent suite of tests. Recently, somebody reported a problem about the unit tests failing. This was odd because "they work for me", but odder still was that the tests were only failing in the afternoon, after 4pm.

Since I live in the UK, all of the development work and testing happens in the GMT/BST timezones. And my host, well that's located in Canada so I was fairly confused when somebody had reported a bug that suggested there were problems related to the time zone in which the code runs.

After a bit of digging around, I found the problem. I was trying to be a little bit cleverer in my unit tests than perhaps I should have been. All of the failing tests had the same root cause - a java.text.SimpleDateFormat instance was being used as a quick and easy way to generate the expected result of a test. Inside of Pebble, there are lots of places that date formatters are used but there's one crucial difference - they've been made aware of an explicit time zone whereas the formatters in the tests hadn't.

This has taught me an important lesson. Either (a) be very careful when generating dynamic values for expected test results or (b) just make the tests more explicit through the use of known data values. Test the tests, or keep them simple.

Read: Who tests the tests?

Topic: IMG_2719.JPG [Flickr] Previous Topic   Next Topic Topic: [May 17, 2006 15:15 PDT] 8 Links

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use