After making changes, you should make sure they are covered by Unit Tests. If the existing UTs are not covering your changes, please, update them and/or create new ones.
-
Make sure you are not breaking the existing UTs by running them locally.
-
Go to the project root directory
# navigate to the repository cd communication-services-authentication-hero-csharp/
-
run the existing unit tests
# Run UTs dotnet run test
-
-
If your change is not covered by the existing UTs, you will need to create new ones.
-
Tests folder structure
All UTs should be defined under the tests folder which is structured as follow:
- controllers
- controllerNameUnitTests.cs - implements a test suite for this controller method.
- services
- serviceNameUnitTests.cs - implements a test suite for this service method.
- controllers
-
If your change is in an existing method, simply add UTs in the corresponding test suite.
For example, if your change is in
UserControllerUnitTests.CreateACSUser_Returns_Status201
, add UTs to tests/UntiTests/Controllers/UserControllerUnitTests.cs. -
If your change is in a new service or controller, create a new test file (with extension
....UnitTest.cs
) and implement the test suite corresponding to this method.
-
More Information
- To lean more about Unit Testing Best Practices, visit:
- To lean more about How to do unit testing using xUnit, visit:
- Next: Submit a PR
- Previous: Test Your Changes