views:

84

answers:

2

With an existing n-tier web application using ASP.net WebForms what is the best approach to get TDD acceptance on the application. What is a good plan to gain acceptance by developers to move forward to write test first code opposed to ignoring the tests while the TDD implementation is in limbo?

Knowing there will be a large "in-limbo" time of low coverage: What areas of the model do you start writing tests for first? Critical use areas, or new development?

+2  A: 

ASP.Net webforms is notoriously hard to build unit tests for due to the built in dependencies on static HttpApplication and HttpContext objects, and the leaky abstraction of the Page lifecycle.

That being said, it's always much much easier to start writing tests for new code, rather than spending any time going back and covering old code. Old code will need to be refactored heavily to allow for proper testing.

womp
+1  A: 

I agree with womp, unit testing and WebForms is hard. Especially if most of your logic is embedded in the code behind files.

I have found it helpful to create functional tests first using something like Selenium. With some decent functional test coverage I can then start refactoring, adding unit tests as I go.

Keith Bloom
I agree. Retrofitting unit tests in this context is very hard. Retrofitting acceptance tests with Selenium, WatiN, or maybe the new test tools of VS2010, is however quite easy.
Martin R-L