Category Archives: TDD

UI Automated Testing with Sitecore


Automated Unit Testing with Sitecore can be a bit tricky because of the context and configuration that goes along with Sitecore, but from a pure UI perspective, testing can be automated with a screenshot comparison approach. I posted an article over at Code Project called Screenshot Smoke Testing. I came up with this approach for my current client witch is a Sitecore engagement. This approach would actually work with any ASP.NET project, not just Sitecore and it  allows one to catch a number of issues that could surface while writing very little code.

Instead of having to write a test script for every element on the page, the test can simply take screenshots of the site and compare them against approved versions. If there is a difference, than the delta would get highlighted and the test would fail.

Feel free to check out the article and let me know what you think:


Unit Testing with an InMemory Database and NBuilder

I am throwing a lot of cycles to my Ergo project lately. I will go into more detail of the Ergo project later when it starts to take more shape and get some legs but one thing it is allowing me to do is get back to a true TDD project. A couple of cool things I have introduced to my unit tests are NBuilder and leveraging Fluent NHibernate and SQLite InMemory to make testing the NHibernate layer a bit easier.

When using NHibernate you generally only need to test 3 things:

  • The Properties are being persisted
  • Cascading works as expected
  • Queries return the correct results

By using an in memory SQLite database we can do this testing while keeping our unit tests nice and speedy. Below is my InMemoryDatabaseTest class that my unit tests can inherit from to test our NHibernate layer.

unit testing1

Now that we have our InMemoryDatabaseTest class setup, we can structure our unit tests like below. One nifty class I found today that you will see in the screenshot is the Builder class. This is from and So instead of having to create a new Page instance and populate it with a bunch of dummy data I can just use 1 line of code to new up a Page which I can then persist to the InMemory database and then use it to Assert against when I query.

unit testing2