codeflood logo

Dreamcore AU 2011

It was my great pleasure to present at Sitecore’s Dreamcore event in Sydney, Australia this week. This was the first time the conference was held in Australia and it was fantastic with lots of great speakers and interesting people.

My session was titled “Testing Strategies for Sitecore” and was run in the developer stream, so it focused on automated/unit testing. As promised for everyone who attended my session, here is the code for my demo site and test project, as well as the slides.

The test project shows a few different techniques for automated testing your Sitecore projects including:

  • Testing pages over HTTP
  • Testing using a web browser driver (WatiN)
  • Instantiating a Sitecore control
  • Testing within the HTTP Context
  • Testing without an HTTP Context

I’ve covered all of the above techniques before, except for the last one, testing without an HTTP Context. I’ll cover that technique in detail in a future post.

Comments

Nick Williams

apparently there's this secret feature in c# where you can write code against this thing called an "interface". i hear it helps testability and decoupling components of a system? i'm slightly cynical of these bold claims, but maybe someone will whisper the secret in sitecore's ear at some point, spurring them to investigate the validity of these claims.

ko

Thanks for putting up your code and slides, I got a lot out of your session and we're looking and implementing this sort of stuff now within our org.

Alistair Deneys

It's a shame I ran out of time in my session cause Tim Ward from Sitecore Australia was going to do a bit on the end of my session to tell us about the things coming in the next major version of Sitecore that will aid in testing. And it looks like Sitecore have been reading the same books you have. Interfaces, interfaces, interfaces. Of course I'll fill you all in when I get more details...

KP

Thanks for all you good bloggposts! I've tried using the XslFile.RenderAsText, but for some reason it do not output anything? Eventhough the items is created?
How you tried that? The testrunner works and outputs:
Expected string length 7 but was 0. Strings differ at index 0. Expected: "Child 2" But was: -----------^ at NUnit.Framework.Assert.That(Object actual, IResolveConstraint expression, String message, Object[] args) at NUnit.Framework.Assert.AreEqual(Object expected, Object actual) at Netlab.Testing.Renderings.NavTest.InclusionAndName() in C:\Visual Studio 2010\Projects\Citify\Citify.no\Trunk\Citify.Website\Netlab.Testing\Renderings\NavTest.cs:line 60
Suggestions?

Alistair Deneys

Hi KP, Did you set the Sitecore.Context.Item property first so the rendering knew where to pull content from? To see if it's a rendering or context issue, try outputting some static text from your rendering and see if that's returned from the "RenderAsText" method.

Alistair Deneys : It’s a shame I ran out of time in my session cause Tim Ward from Sitecore Australia was going to do a bit on the end of my session to tell us about the things coming in the next major version of Sitecore that will aid in testing. And it looks like Sitecore have been reading the same books you have. Interfaces, interfaces, interfaces. Of course I’ll fill you all in when I get more details…
Do you have any update on forthcoming testing support in Sitecore?

Alistair Deneys

Hi Kevin, All I've been told is lots of interfaces (IDatabase, IItem), so mocking will be a breeze and unit tests can be just that, "unit" tests and not integration tests.

Leave a comment

All fields are required.