Re: Best Way to Pass Info Between Objects?
Arved Sandstrom wrote:
I will also point out, neutrally, that what has been advocated here for
unit tests in support of software component design is test driven
development (TDD), or *close to it*. Lew and Martin both describe a
process very close to it; I don't have enough information to say whether
they are _requiring_ that all of the first tests fail (which is
necessary in classic TDD), or simply assuming that many/most will.
When you write that up-front test and keep it simple, you don't have to run
the test to know it'll fail initially.
I, too, write implementation before the unit test. Or did. I've learned that
unit tests save effort and eliminate bugs, the more so earlier you write them,
up to concurrently with implementation.
Covering your code with unit tests, you are freed of doubt whether you're free
of unit-level bugs. (Ducking tomatoes. Hey, don't get mad at me if you wrote
insufficient unit tests. Fix them.)
I'm working on assimilating this lesson properly myself. New habits displace
ingrained patterns only by dint of diligence. My transformation is helped by
how little overhead a test-propelled approach introduces, and how much faster
and better development goes.
In any case the OP could read up on TDD to get more background on what's
being described here. A salient point is that these are unit tests that
support software component design; they are not unit tests for defect
detection [1].
....
1. And how much of one's time one should devote to writing unit tests
for _testing_, as opposed to higher-level tests, is a different discussion.
Would you expound on this distinction, please? I've heard a lot of
distinctions drawn around tests and unit tests in particular, but never this.
Notes:
1. Annotations. Annotations.
2. EasyMock - beyond testing, a requirements scripter. Yes, it's easy.
3. 'assert'. It's pure Zen.
4. Dependency Injection.
5. Package-private methods. (No, not every method. Really?)
--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg