TDD & BDD

I received a comment on my blog yesterday from Chris Corcino. Chris pointed out that he has a hard time to get started with TDD and BDD with Sitecore. Basically it’s nearly impossible to emulate the ASP.NET HttpContext. And this makes it impossible to do some additional mocking. As Sitecore is really designed around the HttpContext, it’s not so easy to create you own IServiceProvider implementation. Actually Microsoft confirms this problems otherwise they wouldn’t have to bring the MVC model as a replacement for the Control model.
I’m not sure if I satisfy you completely with one of the following answers, but these 2 options might be valuable for you to do at least soem testing:

  1. Internally we use a mix of tools to do some intensive testing of for example our Security Model. I know the R&D team uses a trick to emulate the HttpContext: start it regular using the Web tester built-into Visual Studio Team System – Test Edition. Then you can run your tests from Visual Studio.
  2. Another option would be to use the DomainObjects module created by Mark Cassidy. This allows you to create a Domain layer. As this layer is basically the one you want to test, you might be able to replace the ‘Sitecore connectors’ of the module with some mock objects.

Hopefully this helped. Feel free to submit your comments.

One thought on “TDD & BDD”

  1. Or you could use a web control that executed NUnit tests on a webform running in sitecore (possible to obatin code coverage also, with tools like NCover), thats the way I do it until I switch to MSTEST 😉

Comments are closed.