Originally posted by Jeanne Boyarsky:
1) Do you prefer instantiating objects (like Calculator) inline or in the setup?
I was avoiding the use of setUp() in favor of less new stuff to learn for a beginner. Indeed, I often write test classes which don't have anything else than assert*() in the test methods and with all the setup and execution performed in the setUp(). Although I guess I leave the execution part into the test methods themselves most of the time.
Originally posted by Jeanne Boyarsky:
2) Do you find value in using the assertEquals(string, int, int) signature? I've seen it listed as a best practice, but there doesn't seem to be any value if there is only one assert in the method. (If there is more than one assert, I understand why it is useful.)
I do use the overloaded "string" versions of assert methods every now and then, mostly in those situations when the statement itself is a bit cryptic and I feel the use of the "description" argument will be prettier than splitting the assertion statement itself into temporary variables or something like that.
One specific situation where I use the assert*(String, ...) versions is with some sort of data-driven tests where I'm looping over an array, comparing each element to something else, etc.