Posts
SXA CLI Installation Troubleshooting
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.
Configuring item children
Probably one of the most used item operations is requesting its children. FakeDb typically configures item hierarchy in the db context setup block (see
using
statement). Likely, for mocks that is not needed. In this post I’ll show few advanced ways to extendItemCustomization
in order to add subitems to a mocked item.Testing content tree via mocked item axes
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.
Switching from FakeDb to mocks
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.