I imagine by now, everyone has seen the Waterfall 2006 Conference. In the spirit of their Refuctoring presentation, I would like to present an interesting topic: "Design Driven Testing"
In Design Driven Testing, your painstakingly crafted, flexible code
determines the types of unit tests you write. Because these tests will need
to exercise your code without requiring changes to the design, they
may need additional complexity. But as everyone knows, it's easier to test one big method than several small ones!
Some implementation suggestions:
- Generate test data - since your methods under test are now large and
complicated flexible, your test data needs to be a bit more complex. With a few well placed unix scripts, you can generate the java code necessary to test your java code.
- Use smoke tests - There's no need to test every possible combination of inputs. With a large flexible method, that wouldn't be very pragmatic. Instead, try a happy-path test. If you can run the logic through a couple common scenarios, it probably won't break when boundary conditions arise. Feel confident in your programming skills!