# Video

# Setting Up For Unit Testing With MSTest (opens new window)

The stubbed project created by OpenAPI Generator has given us enough code so that we can write tests which reference the various controllers. One issue which developers often struggle with while practicing Test-Driven Development is that you cannot write a test for code which doesn't exist in strongly-typed languages, but the generated code allows us to overcome that difficulty.

  1. Add a new Tests project to your solution
    cd <solution root>
    dotnet new mstest -o src/RedHat.TodoList.Tests
  2. Change directory to the Tests project and add a reference to the project being tested
    cd src/RedHat.TodoList.Tests
    dotnet add reference ../RedHat.TodoList/RedHat.TodoList.csproj
  3. Install the Moq package for mocking objects in tests
    dotnet add package Moq
  4. From this point forward, we will attempt to write tests first and then implement our code to satisfy those tests.
Last Updated: 9/2/2023, 4:02:00 PM