Skip to content

Improve automated test run speed for Aspire-enabled Boilerplate projects by removing unnecessary resources #12332

@yasmoradi

Description

@yasmoradi

Problem

When running dotnet test on an Aspire-enabled bit Boilerplate project, the Aspire host starts all resources defined in the AppHost — including UI/admin tools, dev tunnels, telemetry listeners, and MAUI device emulators. These services add significant startup time without providing any value during automated tests.

As mentioned in our .docs/20- .NET Aspire.md documentation, by default each time the AppHost restarts, all Docker instances start from the very beginning — making this especially time-consuming.

Solution

In TestsAssemblyInitializer.cs, after creating the DistributedApplicationTestingBuilder, remove the following unnecessary resources before building and starting the app:

  • DevTunnelResource / DevTunnelPortResource
  • Database admin UIs: DbGateContainerResource (SqlServer), PgAdminContainerResource (PostgreSQL), PhpMyAdminContainerResource (MySQL), SqliteWebResource (Sqlite)
  • Redis UI tools: RedisInsightResource, RedisCommanderResource
  • MAUI device resources: MauiAndroidDeviceResource, MauiAndroidEmulatorResource
  • OTLP loopback resource

This keeps only the essential infrastructure services (databases, Redis, etc.) running during tests.

Files to change

  • src/Templates/Boilerplate/Bit.Boilerplate/src/Tests/Infrastructure/TestsAssemblyInitializer.cs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions