Microsoft.AspNetCore.Mvc.Testing
10.0.0-preview.2.25164.1
Prefix Reserved
dotnet add package Microsoft.AspNetCore.Mvc.Testing --version 10.0.0-preview.2.25164.1
NuGet\Install-Package Microsoft.AspNetCore.Mvc.Testing -Version 10.0.0-preview.2.25164.1
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.0-preview.2.25164.1" />
paket add Microsoft.AspNetCore.Mvc.Testing --version 10.0.0-preview.2.25164.1
#r "nuget: Microsoft.AspNetCore.Mvc.Testing, 10.0.0-preview.2.25164.1"
// Install Microsoft.AspNetCore.Mvc.Testing as a Cake Addin #addin nuget:?package=Microsoft.AspNetCore.Mvc.Testing&version=10.0.0-preview.2.25164.1&prerelease // Install Microsoft.AspNetCore.Mvc.Testing as a Cake Tool #tool nuget:?package=Microsoft.AspNetCore.Mvc.Testing&version=10.0.0-preview.2.25164.1&prerelease
About
Microsoft.AspNetCore.Mvc.Testing
provides support for writing integration tests for ASP.NET Core apps that utilize MVC or Minimal APIs.
Key Features
- Copies the dependencies file (
.deps.json
) from the System Under Test (SUT) into the test project'sbin
directory - Sets the content root to the SUT's project root so that static files are found during test execution
- Provides the
WebApplicationFactory
class to streamline bootstrapping the SUT withTestServer
How to Use
To use Microsoft.AspNetCore.Mvc.Testing
, follow these steps:
Installation
To install the package, run the following command from the directory containing the test project file:
dotnet add package Microsoft.AspNetCore.Mvc.Testing
Configuration
To configure the test app, follow these steps:
- Specify the Web SDK in the test project file (
<Project Sdk="Microsoft.NET.Sdk.Web">
). - Add references to the following packages:
xunit
xunit.runner.visualstudio
Microsoft.NET.Test.Sdk
- Add a test class to the test project:
public class BasicTests : IClassFixture<WebApplicationFactory<Program>> { private readonly WebApplicationFactory<Program> _factory; public BasicTests(WebApplicationFactory<Program> factory) { _factory = factory; } [Theory] [InlineData("/")] [InlineData("/Index")] [InlineData("/About")] [InlineData("/Privacy")] [InlineData("/Contact")] public async Task Get_EndpointsReturnSuccessAndCorrectContentType(string url) { // Arrange var client = _factory.CreateClient(); // Act var response = await client.GetAsync(url); // Assert response.EnsureSuccessStatusCode(); // Status Code 200-299 Assert.Equal("text/html; charset=utf-8", response.Content.Headers.ContentType.ToString()); } }
Additional Documentation
For additional documentation and examples, refer to the official documentation on integration testing in ASP.NET Core.
Feedback & Contributing
Microsoft.AspNetCore.Mvc.Testing
is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net10.0 is compatible. |
-
net10.0
- Microsoft.AspNetCore.TestHost (>= 10.0.0-preview.2.25164.1)
- Microsoft.Extensions.DependencyModel (>= 10.0.0-preview.2.25163.2)
- Microsoft.Extensions.Hosting (>= 10.0.0-preview.2.25163.2)
NuGet packages (234)
Showing the top 5 NuGet packages that depend on Microsoft.AspNetCore.Mvc.Testing:
Package | Downloads |
---|---|
Alba
Supercharged integration testing for ASP.NET Core HTTP endpoints |
|
Ardalis.HttpClientTestExtensions
Helpful extension methods to use when testing APIs in Functional Tests with xUnit. |
|
Volo.Abp.AspNetCore.TestBase
Package Description |
|
Reo.Core.IntegrationTesting
Package Description |
|
FastEndpoints.Testing
Integration/End-To-End testing helper library for FastEndpoints |
GitHub repositories (276)
Showing the top 5 popular GitHub repositories that depend on Microsoft.AspNetCore.Mvc.Testing:
Repository | Stars |
---|---|
jellyfin/jellyfin
The Free Software Media System - Server Backend & API
|
|
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
|
|
jasontaylordev/CleanArchitecture
Clean Architecture Solution Template for ASP.NET Core
|
|
ardalis/CleanArchitecture
Clean Architecture Solution Template: A proven Clean Architecture Template for ASP.NET Core 9
|
|
bitwarden/server
Bitwarden infrastructure/backend (API, database, Docker, etc).
|
Version | Downloads | Last updated | |
---|---|---|---|
10.0.0-preview.2.25164.1 | 897 | 3/18/2025 | |
10.0.0-preview.1.25120.3 | 2,397 | 2/25/2025 | |
9.0.3 | 300,853 | 3/11/2025 | |
9.0.2 | 692,241 | 2/11/2025 | |
9.0.1 | 824,444 | 1/14/2025 | |
9.0.0 | 1,662,974 | 11/12/2024 | |
9.0.0-rc.2.24474.3 | 36,500 | 10/8/2024 | |
9.0.0-rc.1.24452.1 | 18,469 | 9/10/2024 | |
9.0.0-preview.7.24406.2 | 7,010 | 8/13/2024 | |
9.0.0-preview.6.24328.4 | 10,726 | 7/9/2024 | |
9.0.0-preview.5.24306.11 | 3,221 | 6/11/2024 | |
9.0.0-preview.4.24267.6 | 2,208 | 5/21/2024 | |
9.0.0-preview.3.24172.13 | 69,663 | 4/11/2024 | |
9.0.0-preview.2.24128.4 | 3,297 | 3/12/2024 | |
9.0.0-preview.1.24081.5 | 23,875 | 2/13/2024 | |
8.0.14 | 230,786 | 3/11/2025 | |
8.0.13 | 695,656 | 2/11/2025 | |
8.0.12 | 909,289 | 1/14/2025 | |
8.0.11 | 2,883,500 | 11/12/2024 | |
8.0.10 | 4,340,711 | 10/8/2024 | |
8.0.8 | 5,415,343 | 8/13/2024 | |
8.0.7 | 3,887,928 | 7/9/2024 | |
8.0.6 | 3,541,116 | 5/28/2024 | |
8.0.5 | 1,598,873 | 5/14/2024 | |
8.0.4 | 3,891,719 | 4/9/2024 | |
8.0.3 | 2,770,316 | 3/12/2024 | |
8.0.2 | 2,739,842 | 2/13/2024 | |
8.0.1 | 3,129,251 | 1/9/2024 | |
8.0.0 | 4,116,937 | 11/14/2023 | |
8.0.0-rc.2.23480.2 | 56,597 | 10/10/2023 | |
8.0.0-rc.1.23421.29 | 50,071 | 9/12/2023 | |
8.0.0-preview.7.23375.9 | 10,364 | 8/8/2023 | |
8.0.0-preview.6.23329.11 | 27,551 | 7/11/2023 | |
8.0.0-preview.5.23302.2 | 12,670 | 6/13/2023 | |
8.0.0-preview.4.23260.4 | 225,403 | 5/16/2023 | |
8.0.0-preview.3.23177.8 | 3,245 | 4/11/2023 | |
8.0.0-preview.2.23153.2 | 2,008 | 3/14/2023 | |
8.0.0-preview.1.23112.2 | 40,920 | 2/21/2023 | |
7.0.20 | 362,108 | 5/28/2024 | |
7.0.19 | 60,956 | 5/14/2024 | |
7.0.18 | 163,662 | 4/9/2024 | |
7.0.17 | 332,241 | 3/12/2024 | |
7.0.16 | 355,547 | 2/13/2024 | |
7.0.15 | 522,514 | 1/9/2024 | |
7.0.14 | 902,087 | 11/14/2023 | |
7.0.13 | 1,588,651 | 10/24/2023 | |
7.0.12 | 688,052 | 10/10/2023 | |
7.0.11 | 2,445,730 | 9/12/2023 | |
7.0.10 | 1,346,444 | 8/8/2023 | |
7.0.9 | 1,188,438 | 7/11/2023 | |
7.0.8 | 866,642 | 6/22/2023 | |
7.0.7 | 438,284 | 6/13/2023 | |
7.0.5 | 2,769,241 | 4/11/2023 | |
7.0.4 | 1,595,235 | 3/14/2023 | |
7.0.3 | 1,426,961 | 2/14/2023 | |
7.0.2 | 1,458,767 | 1/10/2023 | |
7.0.1 | 833,274 | 12/13/2022 | |
7.0.0 | 2,491,526 | 11/7/2022 | |
7.0.0-rc.2.22476.2 | 65,863 | 10/11/2022 | |
7.0.0-rc.1.22427.2 | 21,568 | 9/14/2022 | |
7.0.0-preview.7.22376.6 | 7,601 | 8/9/2022 | |
7.0.0-preview.6.22330.3 | 2,411 | 7/12/2022 | |
7.0.0-preview.5.22303.8 | 9,289 | 6/14/2022 | |
7.0.0-preview.4.22251.1 | 2,073 | 5/10/2022 | |
7.0.0-preview.3.22178.4 | 1,211 | 4/13/2022 | |
7.0.0-preview.2.22153.2 | 971 | 3/14/2022 | |
7.0.0-preview.1.22109.13 | 4,998 | 2/17/2022 | |
6.0.36 | 419,595 | 11/12/2024 | |
6.0.35 | 165,315 | 10/8/2024 | |
6.0.33 | 688,018 | 8/13/2024 | |
6.0.32 | 250,144 | 7/9/2024 | |
6.0.31 | 391,274 | 5/28/2024 | |
6.0.30 | 138,019 | 5/14/2024 | |
6.0.29 | 604,386 | 4/9/2024 | |
6.0.28 | 361,909 | 3/12/2024 | |
6.0.27 | 552,249 | 2/13/2024 | |
6.0.26 | 815,201 | 1/9/2024 | |
6.0.25 | 1,446,934 | 11/14/2023 | |
6.0.24 | 787,348 | 10/24/2023 | |
6.0.23 | 527,525 | 10/10/2023 | |
6.0.22 | 862,921 | 9/12/2023 | |
6.0.21 | 1,234,347 | 8/8/2023 | |
6.0.20 | 1,132,375 | 7/11/2023 | |
6.0.19 | 693,720 | 6/22/2023 | |
6.0.18 | 454,116 | 6/13/2023 | |
6.0.16 | 2,354,646 | 4/11/2023 | |
6.0.15 | 1,264,665 | 3/14/2023 | |
6.0.14 | 1,634,907 | 2/14/2023 | |
6.0.13 | 2,123,337 | 1/10/2023 | |
6.0.12 | 2,392,698 | 12/13/2022 | |
6.0.11 | 2,625,006 | 11/7/2022 | |
6.0.10 | 4,023,437 | 10/11/2022 | |
6.0.9 | 3,075,614 | 9/13/2022 | |
6.0.8 | 3,914,484 | 8/9/2022 | |
6.0.7 | 3,337,339 | 7/12/2022 | |
6.0.6 | 2,449,614 | 6/14/2022 | |
6.0.5 | 3,071,216 | 5/10/2022 | |
6.0.4 | 2,808,060 | 4/11/2022 | |
6.0.3 | 3,053,101 | 3/8/2022 | |
6.0.2 | 2,944,391 | 2/8/2022 | |
6.0.1 | 4,300,213 | 12/14/2021 | |
6.0.0 | 4,794,791 | 11/8/2021 | |
6.0.0-rc.2.21480.10 | 201,259 | 10/12/2021 | |
6.0.0-rc.1.21452.15 | 171,072 | 9/14/2021 | |
6.0.0-preview.7.21378.6 | 7,313 | 8/10/2021 | |
6.0.0-preview.6.21355.2 | 4,133 | 7/14/2021 | |
6.0.0-preview.5.21301.17 | 3,067 | 6/15/2021 | |
6.0.0-preview.4.21253.5 | 2,505 | 5/24/2021 | |
6.0.0-preview.3.21201.13 | 2,838 | 4/8/2021 | |
6.0.0-preview.2.21154.6 | 817 | 3/11/2021 | |
6.0.0-preview.1.21103.6 | 916 | 2/12/2021 | |
5.0.17 | 669,861 | 5/10/2022 | |
5.0.16 | 106,797 | 4/11/2022 | |
5.0.15 | 210,190 | 3/8/2022 | |
5.0.14 | 205,280 | 2/8/2022 | |
5.0.13 | 493,762 | 12/14/2021 | |
5.0.12 | 596,204 | 11/7/2021 | |
5.0.11 | 1,033,785 | 10/12/2021 | |
5.0.10 | 1,052,692 | 9/14/2021 | |
5.0.9 | 1,160,301 | 8/10/2021 | |
5.0.8 | 917,010 | 7/13/2021 | |
5.0.7 | 1,186,053 | 6/8/2021 | |
5.0.6 | 929,496 | 5/11/2021 | |
5.0.5 | 1,360,340 | 4/6/2021 | |
5.0.4 | 821,587 | 3/9/2021 | |
5.0.3 | 982,455 | 2/9/2021 | |
5.0.2 | 935,289 | 1/12/2021 | |
5.0.1 | 563,802 | 12/8/2020 | |
5.0.0 | 1,580,356 | 11/9/2020 | |
5.0.0-rc.2.20475.17 | 14,867 | 10/13/2020 | |
5.0.0-rc.1.20451.17 | 7,734 | 9/14/2020 | |
5.0.0-preview.8.20414.8 | 9,105 | 8/25/2020 | |
5.0.0-preview.7.20365.19 | 3,546 | 7/21/2020 | |
5.0.0-preview.6.20312.15 | 2,002 | 6/25/2020 | |
5.0.0-preview.5.20279.2 | 828 | 6/10/2020 | |
5.0.0-preview.4.20257.10 | 1,458 | 5/18/2020 | |
5.0.0-preview.3.20215.14 | 1,837 | 4/23/2020 | |
5.0.0-preview.2.20167.3 | 831 | 4/2/2020 | |
5.0.0-preview.1.20124.5 | 1,063 | 3/16/2020 | |
3.1.32 | 424,192 | 12/13/2022 | |
3.1.31 | 92,569 | 11/8/2022 | |
3.1.30 | 773,699 | 10/11/2022 | |
3.1.29 | 69,140 | 9/13/2022 | |
3.1.28 | 114,488 | 8/9/2022 | |
3.1.27 | 108,319 | 7/12/2022 | |
3.1.26 | 118,884 | 6/14/2022 | |
3.1.25 | 137,285 | 5/10/2022 | |
3.1.24 | 137,418 | 4/11/2022 | |
3.1.23 | 204,185 | 3/8/2022 | |
3.1.22 | 584,196 | 12/14/2021 | |
3.1.21 | 431,658 | 11/7/2021 | |
3.1.20 | 377,661 | 10/11/2021 | |
3.1.19 | 267,445 | 9/14/2021 | |
3.1.18 | 796,245 | 8/10/2021 | |
3.1.17 | 565,985 | 7/13/2021 | |
3.1.16 | 488,535 | 6/8/2021 | |
3.1.15 | 436,531 | 5/11/2021 | |
3.1.14 | 769,717 | 4/6/2021 | |
3.1.13 | 902,728 | 3/9/2021 | |
3.1.12 | 548,481 | 2/9/2021 | |
3.1.11 | 695,161 | 1/12/2021 | |
3.1.10 | 2,124,367 | 11/9/2020 | |
3.1.9 | 2,314,710 | 10/13/2020 | |
3.1.8 | 2,024,967 | 9/8/2020 | |
3.1.7 | 1,567,447 | 8/11/2020 | |
3.1.6 | 1,760,549 | 7/14/2020 | |
3.1.5 | 2,116,276 | 6/9/2020 | |
3.1.4 | 1,486,165 | 5/12/2020 | |
3.1.3 | 2,395,749 | 3/24/2020 | |
3.1.2 | 1,985,242 | 2/18/2020 | |
3.1.1 | 1,781,987 | 1/14/2020 | |
3.1.0 | 2,134,366 | 12/3/2019 | |
3.1.0-preview3.19555.2 | 2,228 | 11/13/2019 | |
3.1.0-preview2.19528.8 | 1,011 | 11/1/2019 | |
3.1.0-preview1.19508.20 | 1,476 | 10/15/2019 | |
3.0.3 | 108,192 | 2/18/2020 | |
3.0.2 | 57,877 | 1/14/2020 | |
3.0.0 | 2,853,298 | 9/23/2019 | |
3.0.0-rc1.19457.4 | 10,520 | 9/16/2019 | |
3.0.0-preview9.19424.4 | 5,020 | 9/4/2019 | |
3.0.0-preview8.19405.7 | 14,868 | 8/13/2019 | |
3.0.0-preview7.19365.7 | 5,752 | 7/23/2019 | |
3.0.0-preview6.19307.2 | 4,565 | 6/12/2019 | |
3.0.0-preview5-19227-01 | 13,896 | 5/6/2019 | |
3.0.0-preview4-19216-03 | 1,985 | 4/18/2019 | |
3.0.0-preview3-19153-02 | 1,446 | 3/6/2019 | |
3.0.0-preview-19075-0444 | 3,592 | 1/29/2019 | |
3.0.0-preview-18579-0056 | 3,113 | 12/3/2018 | |
2.3.0 | 2,389 | 1/14/2025 | |
2.2.0 | 6,545,578 | 12/3/2018 | |
2.2.0-preview3-35497 | 16,013 | 10/17/2018 | |
2.2.0-preview2-35157 | 4,124 | 9/12/2018 | |
2.2.0-preview1-35029 | 7,237 | 8/22/2018 | |
2.1.3 | 1,469,596 | 10/1/2018 | |
2.1.2 | 363,244 | 8/21/2018 | |
2.1.1 | 992,535 | 6/18/2018 | |
2.1.0 | 836,829 | 5/29/2018 | |
2.1.0-rc1-final | 20,772 | 5/6/2018 | |
2.1.0-preview2-final | 4,781 | 4/10/2018 | |
2.1.0-preview1-final | 3,738 | 2/26/2018 |