Unit testing is Sitecore can be tricky. There are a lots of moving parts. And to truly be able to test, you need to somehow bring all of those parts into a test.
Unit testing could be divided into two different type: regular Unit Tests (just to test BusinessLogic without data relations) and Integration Unit Tests.
In the current article I will focus on Integration Unit Tests. In the futher articles I will describe how to write UnitTests without strong coherence with Sitecore.
So, to accomplish the main goal and have working UnitTests I will try to do the following:
- Execute unit tests within a valid Sitecore context
- Load all current App_Config/Include/ configs at runtime
- Access to all APIs
- Maintain to additional config files
- No scripting involved
According to our goals let’s find a way of how to reach it. It’s mostly screenshots and code samples anyways.