Skip to content
JainalGandhi edited this page Mar 14, 2020 · 3 revisions

Selecting Unit Testing Framework

Because we are using C# for our back-end, we have three main options for unit testing frameworks, XUnit, MSTest/Visual Studio unit testing and Nunit.

MSTest/Visual Studio

This is the unit testing framework that comes with Visual Studio. It is easy to setup and get started. But the issue with this that it can slow and sluggish. Also, because it's built into Visual Studio by Microsoft, it might be difficult to use it with other third part IDEs such as C# Rider.

NUnit

This framework is not depended on a specific company's tools and because of this, it works well with third party IDEs. NUnit is much faster than the MSTest at testing. This could stop us from wasting unnecessary time. The biggest advantage of NUnit is that it is quite similar to JUnit and most of us have experience using it. Also because this is the most popular framework, there is a lot of documentation on it, which will be helpful. But might be slower to set up compared to MSTest because it is not built in but can be quickly installed through installing a Nuget package.

XUnit

This tool is similar to NUnit. Many use this because the terminology a lot more intuitive compared to the others. But the biggest issue with this is that there isn't much documentation on it.

Our decision

We decided to go NUnit because time was an issue. We won't have to spend much time learning it as it is similar to JUnit and there is a lot of documentation on it.

Reference: https://stackify.com/unit-test-frameworks-csharp/

Creating Unit Tests

Source: http://www.alteridem.net/2016/10/03/nunit-unit-tests/

Additional Notes

The ServiceDependencyResolver.cs dependency injector class has been created and can be used to resolve the dependencies required by the controller classes.

Clone this wiki locally