« .NET vs. Java? It's All About Choice | Main | sofake »

2005.09.09

Comments

Thomas Eyde
Good advice, except for the method naming convention: A method can be used in different contexts, and the test code would become messy if we try to cram everything into one test method. I like to use my goals to name my test methods, like: PrintOrder PrintOrderWithInvalidInput LogInvalidPrintedOrder And what would you do if you rename the method? Would you look up all test methods and rename them too? void PrintOrderTest() { order.PrintOrder(); } oops, silly naming. I rename... void PrintOrderTest() { order.Print(); } Hmm. "PrintOrder" looks like a nice test name, but my method is now named "Print"
Todd Girvin
Yeah, I agree that matching the test name to the method being tested isn't *that* important. It's much more important that the name describe the test case. However, I do find myself lumping several tests together in a single test method just by taking several different actions and asserting after each. It could be bad form, but I do split them out if I get more than 3 or so and always split them for different topics. And, it's just a nit, but I do like the 'Test' prefix as opposed to suffix on the TestMethod. But in the end, it's far more important that people do unit testing at all than creating denominational religious wars over such conventions.
mel
glad to see ms preaching tdd.
Lyronne
The reality is that if test driven development is not enforced, i.e. it is not governed by peer review, unit tests get left behind in the wake of tighter project deadlines. Tools to speed up TDD like Resharper etc., and also using TDD only on the complex parts of the system that pay off will help make the efforts in ensuring quality succeed I think. Granular tests are fine if you have the time, but you have to question testing CRUD methods where no constraints exist. That being said subtle constraints may be added over time and the test was left behind. Again design and code reviews can help mitigate this. A culture of wanting it to work is very much needed and must be bought into by project managers etc. when estimating iterations.

The comments to this entry are closed.

November 2008

Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
Blog powered by Typepad

We Like