Adventures in Unit Testing

December 05, 2014

Watch transcription.

I'm quite literally, so furiously, thinking of ways to explain the funky stuff inside my brain. I couldn't explain! You might understand though. In fact, I'd wager you will. 

So I manage a modest multi-site Sitecore solution. There's a lot of shared code. There's also a lot more overrides. At a certain size, a system must be tested so that I know I'm in control and not my old nemesis, EEENTROOPYYYYY !!! ... ; * ' , . (ahem) The only way to know for sure if some piece of code is working properly, is to test it. 

Test coverage, of course, comes with costs. Time to design it, time to build, time to test it. I've been building web tests for this system for years now. I rolled them into a project last april on GitHub named TestStar that uses NUnit and included some unit testing. It's a web app that works beside my Team City server. After a build, unit tests were run. Then the integration environment was updated and web tests were run against it. This offloaded the work my desktop was doing to a single test system that I could then also run in regular intervals. Like daily. Fed to an RSS feed. So I had a history. The tool works well and does an awful lot of work for me. But I now have a second case for its use, and eventually, hopefully I'll find a third

Over time I've accumulated a few modules on the Sitecore Marketplace. Being able to successfully manage all of them is beginning to require I automate my testing. Mostly in this case in the form of unit testing. I typically run a few version (numbers) of Sitecore. I include my projects from a gitroot folder. This way I can include each, multiple times into other solutions. If I add tests to the projects, when I run a build, all needed files for testing can be in any given environment. The easiest way to test this is to have a modular Sitecore <site> that tests itself and other sites. In this way, it's consolidated PLUS (big plus), it can query for items and quite thoroughly test live content. My first iteration of TestStar also had batch scripting ability, if I wire that up in some friendly way, and or Powershell scripting, I'll be back to sleeping at night... (maybe)

After a time, I plan to release the latest source as a module, fully tested and ready for the daily grind. Part of this involves doing some of my favorite work: UI, UX or whatever nomenclature you prefer. For this I'm riffing off Mass Effect 2 and DJ Jazzy Jeff. Haven't decided which background works better. Here's where I'm at:

unit testing: space background unit testing web testing: space background web testing



So I've recorded a quick video walking through how the TestStar will work and how it's built into the Sitecore backend.

Here's a second video on the progress I'm making on TestStar. It's now almost ready for release.