Originally posted by Bill Peck:
Sorry about the blank post.
Regarding Charles' question . . . Say a person was learning Java, but had a decent grasp of programming and software development. How many years of experience, generally speaking, would it take to have even the slightest clue of understanding of Charles' question?
I apologize if that seems a bit ambiguous to anyone not familiar with the terms MF uses, or his article...
TDD =
Test Driven Development
Stub (as it applies to test) = a class that is created (typically) to fulfill a type contract (like a class implementing an interface) yet really has very little to it other than signatures and one or two "implemented" methods.
Mock (as it applies to test) = another "fake" object that implements an interface and can mimic behaviors desirable to a tester.
Basically, as OOP has matured, so has (in some cases) the complexity of the objects we create (or in some cases like
J2EE - forced to create). With that complexity, you optimal will try to create objects that are very specialized, but at some point you will reach critical mass and need to create something that ties everything together. Unit tests for the individual pieces are straight forward, but more complex objects are harder to nail down. By using mocks and/or stubs, a developer writing a test has control over what a certain object will do and how it will act, thus taking one "variable" out of the equation. What MF talks about is whether the goal of a unit test on this type of object should be to test the behavior of the object vs the state of the system. A "classic" TDD'er says, "I know the state before and all I care about is the state of the system after for various inputs". A "mockist" says that how everything interacts is equally important in complex systems (you still have to get the right answer of course).
So, going back to the question at hand - I'm curious about the author's opinion, as it gives some small insight to their general approach to testing.
[ September 24, 2007: Message edited by: Charles Hasegawa ]