Skip to content

Commit 99f2f51

Browse files
committed
Add details about testing. Fixes dotnet#2721
1 parent e49f63f commit 99f2f51

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

docs/testing/overview.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: .NET Aspire testing overview
33
description: Learn how .NET Aspire helps you to test your applications.
4-
ms.date: 02/24/2025
4+
ms.date: 03/11/2025
55
---
66

77
# .NET Aspire testing overview
@@ -12,6 +12,21 @@ By default, the testing builder disables the dashboard and randomizes the ports
1212

1313
To get started writing your first integration test with .NET Aspire, see the [Write your first .NET Aspire test](./write-your-first-test.md) article.
1414

15+
## Testing .NET Aspire solutions
16+
17+
.NET Aspire's testing capabilities are designed specifically for black-box integration testing of your entire distributed application. Unlike unit tests or white-box integration tests, which typically run individual components in isolation, .NET Aspire testing launches your complete application as separate processes, closely simulating real-world scenarios.
18+
19+
Use .NET Aspire testing when you want to:
20+
21+
- Verify end-to-end functionality of your distributed application.
22+
- Ensure interactions between multiple services and resources (such as databases) behave correctly in realistic conditions.
23+
- Confirm data persistence and integration with real external dependencies, like a PostgreSQL database.
24+
25+
If your goal is to test a single project in isolation, run components in-memory, or mock external dependencies, consider using the <xref:Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory%601> instead.
26+
27+
> [!NOTE]
28+
> .NET Aspire tests run your application as separate processes, meaning you won't have direct access to internal services or components from your test code. You can influence application behavior through environment variables or configuration settings, but internal state and services remain encapsulated within their respective processes.
29+
1530
## Disable port randomization
1631

1732
By default, .NET Aspire uses random ports to allow multiple instances of your application to run concurrently without interference. It uses [.NET Aspire's service discovery](../service-discovery/overview.md) to ensure applications can locate each other's endpoints. To disable port randomization, pass `"DcpPublisher:RandomizePorts=false"` when constructing your testing builder, as shown in the following snippet:

0 commit comments

Comments
 (0)