Getting started with Unit Testing in Umbraco just got a whole lot easier!

Around two years ago Umbraco version 8 was released and I was scanning the internet trying to find some documentation on how to do Unit Testing in version 8, without any luck.

No examples or tutorials had yet to be made for this and the official documentation did not have a section on Unit Testing. So I thought: How hard can it be? For more background read this blogpost from Umbraco.com.

After some discussions back and forward with members of the Umbraco Core and Documentation Team I submitted the initial commit for the documentation on 24 May 2019.

The Umbraco Unit Testing Documentation
The result was the official Umbraco Documentation on Unit Testing:

Since then I’ve improved this documentation throughout the years extending it with more examples of how to write tests for different Umbraco components.

But these examples have always been code snippets in a documentation and never an actual project that you could setup locally and run each test without having to copy & paste every single test and try to guess the correct namespace and dependency to install. Until now!

The Umbraco Unit Testing Project
So what I’ve done is I’ve created a solution called Umbraco Unit Testing and added it to a public GitHub repository.

Then I’ve taken every single test in the Unit Testing Documentation and added them to a *.Tests project in this solution and installed all the necessary dependencies and added all the correct namespaces so that this project should be able to clone > build > run without any hazzle or setup.

I will try to keep this project updated when the Documentation grows (shouldn't be a problem since I'm currently the only one contributing to it) or with newer version of Umbraco that might include breaking changes related to the tests.

Please check it out and try it and let me know if something is not working for you and I will do my best to assist you.

Cheers friends!