Skip to content

V. Testing

Frederik Wulf edited this page May 5, 2023 · 4 revisions

Read all about testing. Learn how to run tests and what kind of tests are available.

Content

  1. Unit test per microservice
  2. Integration tests
  3. End-to-end tests or integration tests across the microservices

Unit test per microservice

Within each service folder/solution is a test project usually called <service-name>.Test. This project contains unit tests for the service. The tests are written using xUnit and Moq.

Running the tests

The tests can be executed from the IDE used or from the command line. To run the tests from the command line, navigate to the test project folder and run dotnet test. To run the tests from the IDE access the TestExplorer of your IDE and run the tests (Visual Studio instructions, or Rider instructions)

image

Integration tests

Integration tests are located in the IntegrationTests folder. The tests are written using xUnit and Moq. The tests are using a test server and a test database. The test server is configured to use the test database. The test database is created and seeded with test data before the tests are running. After the tests have run the test database is deleted.

Currently the integration tests are a bit messy to run. Setting them up does only work partly automatically. The database migrations have to executed manually before the tests can be executed. Therefore the integration tests need some more work to be useful.

End-to-end tests or integration tests across the microservices

There is currently no such thing. But it would be a good idea to have some end-to-end tests. It would cover the communication and interaction between all services. For instance one service is raising an event and another service is listening to that event and reacts to it. This is currently not covered, but tests like this could help with that.