Skip to content

An example of integration testing ASP.NET Core Minimal hosting and APIs

License

Notifications You must be signed in to change notification settings

martincostello/dotnet-minimal-api-integration-testing

Integration Testing ASP.NET Core Minimal APIs

Build status codecov

Introduction

This sample project demonstrates techniques you can use for integration testing an ASP.NET Core web application that uses the minimal APIs feature.

The system-under-test used by the sample implements a simple Todo list application with ASP.NET Core using the following technologies:

The tests show how you can write integration tests for the API and User Interface layers of an application that can help you get good coverage of the system-under-test, as well as help give you confidence that the changes you make to an application are ready to ship to a production system.

The tests include demonstrations of the use of the following open source libraries and technologies:

Debugging

To debug the application locally outside of the integration tests, you will need to create a GitHub OAuth app to obtain secrets for the GitHub:ClientId and GitHub:ClientSecret options so that the OAuth user authentication works and you can log into the Todo App UI.

💡 When creating the GitHub OAuth app, use https://localhost:50001/sign-in-github as the Authorization callback URL.

⚠️ Do not commit GitHub OAuth secrets to source control. Configure them with User Secrets instead.

Building and Testing

Compiling the application yourself requires Git and the .NET SDK to be installed (version 8.0.100 or later).

To build and test the application locally from a terminal/command-line, run the following set of commands:

git clone https://github.com/martincostello/dotnet-minimal-api-integration-testing.git
cd dotnet-minimal-api-integration-testing
./build.ps1

Feedback

Any feedback or issues can be added to the issues for this project in GitHub.

Acknowledgements

Thanks to David Fowler (@davidfowl) from the ASP.NET Core team for helping out with resolving issues with Minimal Actions found from testing this sample with the ASP.NET Core 6 pre-releases!

Repository

The repository is hosted in GitHub: https://github.com/martincostello/dotnet-minimal-api-integration-testing.git

License

This project is licensed under the Apache 2.0 license.