While the installation process for SXA CLI appears straightforward and is documented in various blog posts (such as here or here), I encountered several issues that necessitated additional steps. Below, I outline these challenges and their resolutions.
Probably one of the most used item operations is requesting its children. FakeDb typically configures item hierarchy in the db context setup block (see
usingstatement). Likely, for mocks that is not needed. In this post I’ll show few advanced ways to extend
ItemCustomizationin order to add subitems to a mocked item.
In the previous post I showed that FakeDb is not the only way of doing unit testing in Sitecore nowadays. Today I want to grab a real class with tests on FakeDb and create an alternative tests suite based on mocks and AutoFixture. You will see how to grow the test setup and will have a better chance to compare two approaches.
Historically, Sitecore was not a unit test friendly platform. The API consisted of static managers and testing was quite cumbersome. There were different attempts to address that starting from ‘unit testing’ via web runners, using commercial tools that could ‘mock’ statics (like Microsoft Fakes) or just relying on expensive integration testing.