Sitecore Unit Testing is not a Success or is IT ?

On November 28, 2013 I came across this question on StackOverflow – Sitecore Unit Testing is not a success? Luckily I could answer it and provide information to the user dpwulp94 but on the first read I was astonished that we as developers do give up unless there is some motivation or solution for the problems we face. My effort for this blog post is to encourage people to break through the barriers of limitations provided by the initial version of any application. Make the effective changes not only in frameworks but also in the attitude and approach of the common problems faced by Sitecore community developers.

Sitecore Unit Testing is not a success or is it ? dilbert-quality “Unit Testing is always useful for anything that is written in C# (or should I say in OO Language)” is what I said on the post but now the front end frameworks are also rapidly changing for the ability to write tests around it. dpwulp94 was implying that after a good amount of research he was planning to give up (“Should we give up or can we get it working and in what way?”), but giving up for the time being and revisiting it with a fresh approach is the key with testing. All I could suggest again is watching

  1. Another interesting video by codeflood.
  2. Automated Testing with Sitecore V2 video by Alistair Deneys from Hedgehog

and read Alistair Deneys’ blog post Unit Testing in Sitecore is not Scary There are also more Unit Testing videos mentioned in Unit Testing Sitecore using NUnit, serializing content blog post if you want more information on how to do Unit Testing in Sitecore.  Coming back to the StackOverflow answer, I also mentioned that “I can gauge the blockage that you are facing. But have a read of Testing Strategies – Opinionated Advice by Kevin Obee.” Sometimes while doing Unit Testing we loose the focus of being pragmatic and just follow the Unit Testing Principles. Confessing in the answer that “I faced that and establishing the balance would be the key. In no way I am suggesting that you might have gone in this direction, but just suggesting that sometimes taking a step back, reflecting on what we ACTUALLY want to TEST and restarting helps a lot.” After reading through the answer a positive comment by dpwulp94 was “The article of Unit Testing in Sitecore is not scary seems great. But it would be nice if there are some people on StackOverFlow who encountered the same problem, writen above. And (of course) how that was being solved” To this I would completely agree and would like open source isolation testing framework for Sitecore like Sitecore.FakeDb gain more light. If this interests you check out this video by Pavel Veller from BrainJocks Keep open source projects coming and let’s make Sitecore Testing better by the day. Happy Sitecoring !

Unit Testing Sitecore using NUnit, serializing content

A while ago I came across this question on StackOverflow – Unit Testing Sitecore using NUnit, serializing content

I was lucky to successfully answer the question and provide information to the user dpwulp94 and also hope that this answer provided was helpful to other seekers as well.

My effort for this blog post is to put the information together in one place and update it periodically.

Unit Testing Sitecore using NUnit, serializing content

Anyone seeking Unit Testing in Sitecore should watch the below videos and there are plenty of others as well.

Interesting videos on Youtube

  1. Sitecore Unit Testing video by gravypower.
  2. Another interesting video by codeflood.
  3. Most knowledgeable for me was this video by Alistair Deneys from Hedgehog
  4. Advanced Glass Walkthrough video by Mike Edwards from Hedgehog
  5. Automated Testing with Sitecore V2 video by Alistair Deneys from Hedgehog

Other interesting blogs are

  1. Igloo – Unit Testing for Sitecore
  2. iStern – Unit testing with Sitecore Item by Thomas Stern
  3. Mocking Sitecore with MS Fakes Part I and Part II by Thomas Stern
  4. And lastly my preferred Coffee => Coder => Code again by Alistair Deneys
  5. Knifecore’s blog also helped me a lot when I was trying to write tests.
  6. Unit Testing with Sitecore by Reservoir Devs

The topic of Serializing Sitecore objects was also mentioned

We also want to mock the Sitecore data by serializing the Sitecore objects. I have been looking for, but could not find a good tutorial to do this. How can I do this?

Kern Nightingale has got a perfect presentation which will give you insight to how to use it for testing as well.

Would also recommend Sitecore Glimpse by Kevin Obee, the project’s one of the purpose is “provide build scripts that automate the tasks of compiling, testing and packaging the project artifacts to make it easier to open the project up for collaborative development” which he mentions on his blog.

To conclude hope this gives bit more perspective on Unit Testing and Serialization with Sitecore.

Happy Sitecoring!