Skip to content

WontonSam/dotnet-minimal-api-integration-testing

 
 

Repository files navigation

Integration Testing ASP.NET Core Minimal APIs

Build status

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:5001/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 7.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.

About

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

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 73.5%
  • TypeScript 12.9%
  • HTML 7.2%
  • PowerShell 3.6%
  • Batchfile 1.3%
  • JavaScript 0.6%
  • Other 0.9%