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

Folders and files

NameName
Last commit message
Last commit date
Apr 8, 2025
Apr 18, 2025
Nov 12, 2024
Apr 23, 2025
Apr 18, 2025
Apr 6, 2025
Jun 25, 2021
Apr 18, 2025
Sep 28, 2024
Nov 12, 2024
Jun 25, 2021
Apr 9, 2025
Jun 12, 2021
Nov 7, 2022
Jan 30, 2025
Apr 11, 2023
Nov 12, 2024
Apr 6, 2025
Apr 18, 2025
Apr 8, 2025
Apr 8, 2025
Apr 8, 2025
Apr 8, 2025

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 9.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.