juan_gandhi: (Default)
Juan-Carlos Gandhi ([personal profile] juan_gandhi) wrote2007-03-27 04:35 pm

bug of the day

Call a method in a unittest like this:

 public void textHighLightWithPlaceholders() {...


And you will be pleasantly surprised later by the fact that junit does not run this test!

[identity profile] xryun-porosyan.livejournal.com 2007-03-28 12:13 am (UTC)(link)
You can also create a method with the name setup() in your unit test.

It works especially well, if you have a big hierarchy (some sort of framework) of test classes, and you you use this method to initialize generic infrastructure in the base class of this hierarchy ...


[identity profile] xryun-porosyan.livejournal.com 2007-03-28 12:19 am (UTC)(link)
Also, while building a hierarchy of test classes, you may think that it might be a good idea to invoke tearDown() from the setUp() method of your base test class ... just in case something was not cleared ... somehow.

And then, while writing a test class, extending the base class (preferably indirectly), call super.setUp() AT THE END of your setUp() method ...

Disclaimer: I didn't write it this way, I just had to debug it :)