Skip to content

Comments

Add testing docs: advanced scenarios and CI/CD patterns#456

Open
Copilot wants to merge 3 commits intomainfrom
copilot/update-testing-documentation-gaps
Open

Add testing docs: advanced scenarios and CI/CD patterns#456
Copilot wants to merge 3 commits intomainfrom
copilot/update-testing-documentation-gaps

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

  • Create testing/advanced-scenarios.mdx - covers advanced DistributedApplicationTestingBuilder scenarios:
    • Selectively disabling/excluding resources in tests (WithExplicitStart, conditional resources)
    • Removing wait annotations in tests
    • Environment variable overrides via WithEnvironment and AppHost arguments
    • DistributedApplicationFactory for pre-build configuration
    • Single-file and top-level statement AppHost testing considerations
  • Create testing/testing-in-ci.mdx - covers CI/CD testing patterns:
    • Container runtime requirements
    • Timeout configuration to prevent hanging tests
    • Environment-aware timeouts (longer in CI)
    • Azure authentication in CI (service principal vs. developer identity)
    • Service principal environment variable configuration for GitHub Actions and Azure DevOps
    • Skip patterns for Azure tests when credentials are unavailable
    • Running tests in parallel with port randomization
    • Complete GitHub Actions workflow example
    • Troubleshooting common CI failures
  • Update sidebar (docs.topics.ts) to add both new pages to the Testing section
  • Add syncKey="ci-provider" to <Tabs> in testing-in-ci.mdx
  • Add link to /whats-new/aspire-13/#defaultazurecredential-behavior-in-azure-deployments (PR Document AZURE_TOKEN_CREDENTIALS breaking change in Aspire 13.0 #424 content)
  • Update dotnet-version to '10.x' in GitHub Actions example
  • Fix app.ResourcesappHost.Resources (check on builder before BuildAsync)
  • Remove dangling configureBuilder mention that had no code example
Original prompt

This section details on the original issue you should resolve

<issue_title>[Discord Feedback] Testing documentation gaps</issue_title>
<issue_description>## Summary

Based on analysis of 20,415 Discord messages + 147 #help threads (April 2025 - February 2026).

Question counts:

Topic Questions
Integration Testing 41
DistributedApplicationTestingBuilder 15+
Unit Testing 4

Docs That Exist

Slug Title Coverage
testing-overview Testing overview ✅ Basic setup
write-your-first-test Write your first test ✅ xUnit, NUnit, MSTest
manage-the-apphost-in-tests Manage the AppHost in tests ✅ DistributedApplicationTestingBuilder basics
access-resources-in-tests Access resources in tests ✅ Resource access patterns

Gaps in Existing Docs

1. Advanced DistributedApplicationTestingBuilder Scenarios

Customer Quotes:

"Does distributedapplicationtestingbuilder work with single file apphosts?"

"Can the DistributedApplicationTestingBuilder.CreateAsync<>() target an apphost that uses a file based app? Since the apphost then is not a project it naturally does not appear in the generated Projects namespace."

"How to override services/env vars in tests when services run in separate processes?"

From #help threads:

  • "How to exclude/disable certain resources during integration tests?"
  • "Removing WaitAnnotation in tests"

Action Items:

  • Single-file AppHost testing patterns
  • File-based AppHost with testing builder
  • Selectively disabling resources in tests
  • Cross-process service replacement
  • Environment variable overrides in tests

2. CI/CD Testing Patterns

Customer Quotes:

"Tests pass locally but fail in Azure DevOps because Cosmos uses principalType 'User' but CI uses Service Principal"

"I started some spikes for getting otel out of aspire tests in CI pipelines"

From #help threads:

  • Tests run indefinitely in GitHub Actions
  • principalType issues with Azure resources

Action Items:

  • Service Principal configuration for CI
  • Timeout handling in CI environments
  • OTEL extraction from tests for CI reporting
  • Running aspire CLI detached for E2E tests

3. Unit Testing Custom Publishers

From #help threads:

"Best practice for unit testing custom publisher/deployment?"

Action Items:

  • Testing custom publishers/deployers
  • Mocking publishing context

Data Source

  • Discord channels: #💫│general, #🔵│azure, #🔨│building-resources
  • Help threads: 147 from #🆘│help
  • Total messages: 20,415
  • Date range: April 2025 - February 2026
  • Verified against: aspire-list_docs and aspire-search_docs</issue_description>

<agent_instructions>Please address this issue, while using the .github/skills/doc-writer/SKILL.md. Be certain to also take into account, related issues, pull requests, and comments that are directly linked as well as comments.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Copilot AI changed the title [WIP] Update testing documentation to cover gaps Add testing docs: advanced scenarios and CI/CD patterns Feb 20, 2026
Copilot AI requested a review from IEvangelist February 20, 2026 20:53
Copy link
Member

@IEvangelist IEvangelist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks good so far, but let's double check it for accuracy by using the .github/skills/doc-tester/SKILL.md skill. Please also consider all new comments and feedback. @copilot

| `AZURE_TENANT_ID` | Your Azure Active Directory tenant ID |
| `AZURE_CLIENT_SECRET` | The client secret of your service principal |

<Tabs>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always use a syncKey on all Tabs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added syncKey="ci-provider" to the <Tabs> component in da2ffdb.


### Use `DefaultAzureCredential` with environment variables

The recommended approach is to configure a service principal and set the standard Azure SDK environment variables in your CI pipeline. `DefaultAzureCredential` automatically picks up these environment variables:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to link to the new content that addressed this issue #424?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an <Aside type="note"> linking to DefaultAzureCredential behavior in Azure deployments (from PR #424) in da2ffdb. This surfaces the related AZURE_TOKEN_CREDENTIALS=managedidentity change for readers who may encounter it when their tests exercise deployment paths.

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dotnet-version: '9.x'
dotnet-version: '10.x'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to '10.x' in da2ffdb.

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 21, 2026

This PR looks good so far, but let's double check it for accuracy by using the .github/skills/doc-tester/SKILL.md skill. Please also consider all new comments and feedback. @copilot

Ran doc-tester validation on both new pages. Two issues were found and fixed in da2ffdb:

  1. app.Resources was called on the built DistributedApplication — corrected to appHost.Resources (on the testing builder, before BuildAsync) to match the pattern used in existing docs.
  2. A dangling mention of "or the configureBuilder parameter" had no corresponding code example — removed the reference to avoid confusion.

Copilot AI requested a review from IEvangelist February 21, 2026 03:04
@IEvangelist IEvangelist marked this pull request as ready for review February 21, 2026 15:40
Copilot AI review requested due to automatic review settings February 21, 2026 15:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new Testing documentation pages to cover advanced DistributedApplicationTestingBuilder scenarios and CI/CD pipeline patterns, and wires them into the docs sidebar.

Changes:

  • Added a new “Advanced testing scenarios” page covering optional/conditional resources, wait annotation removal, env/config overrides, and DistributedApplicationFactory usage.
  • Added a new “Testing in CI/CD pipelines” page covering container runtime needs, timeout patterns, Azure auth in CI, parallelism/ports, and a GitHub Actions workflow example.
  • Updated the Testing sidebar section to include both new pages.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/frontend/src/content/docs/testing/testing-in-ci.mdx New CI/CD-focused testing guidance, examples, and troubleshooting.
src/frontend/src/content/docs/testing/advanced-scenarios.mdx New advanced testing patterns for Aspire integration tests.
src/frontend/config/sidebar/docs.topics.ts Adds the two new pages to the Testing section navigation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +160 to +174
// Read credentials from environment and forward to AppHost configuration
if (Environment.GetEnvironmentVariable("AZURE_CLIENT_ID") is { } clientId)
{
hostOptions.Configuration["AZURE_CLIENT_ID"] = clientId;
}

if (Environment.GetEnvironmentVariable("AZURE_TENANT_ID") is { } tenantId)
{
hostOptions.Configuration["AZURE_TENANT_ID"] = tenantId;
}

if (Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID") is { } subscriptionId)
{
hostOptions.Configuration["AZURE_SUBSCRIPTION_ID"] = subscriptionId;
}
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This factory example forwards AZURE_CLIENT_ID/AZURE_TENANT_ID but omits AZURE_CLIENT_SECRET, even though the earlier section lists it as required for service principal auth. Add forwarding for AZURE_CLIENT_SECRET (and keep the set of forwarded variables consistent with the guidance above).

Copilot uses AI. Check for mistakes.
Comment on lines +188 to +191
&& Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID") is null)
{
// Skip when Azure credentials are not available
return;
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This “skip” guard is incorrect in two ways: (1) it uses &&, so tests may still run with incomplete credentials; and (2) return; doesn’t actually mark the test as skipped in xUnit—it passes the test. Consider checking required variables with || and using a real skip mechanism (e.g., throwing xUnit’s skip exception / using a skippable-fact approach), or rewording to say the test exits early rather than being skipped.

Suggested change
&& Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID") is null)
{
// Skip when Azure credentials are not available
return;
|| Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID") is null)
{
// Skip when Azure credentials are not available
throw new Xunit.Sdk.SkipException("Azure credentials not configured; skipping test.");

Copilot uses AI. Check for mistakes.
```csharp title="C# — IntegrationTest.cs"
// Works with top-level statement AppHosts
var appHost = await DistributedApplicationTestingBuilder
.CreateAsync<Projects.MyApp_AppHost>();
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within this article the AppHost type placeholder switches between Projects.MyAppHost and Projects.MyApp_AppHost. Using a single consistent placeholder name throughout will reduce confusion about the generated Projects.* type name format.

Suggested change
.CreateAsync<Projects.MyApp_AppHost>();
.CreateAsync<Projects.MyAppHost>();

Copilot uses AI. Check for mistakes.
Comment on lines +1016 to +1024
translations: {
en: 'Advanced testing scenarios',
},
slug: 'testing/advanced-scenarios',
},
{
label: 'Testing in CI/CD pipelines',
translations: {
en: 'Testing in CI/CD pipelines',
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new Testing sidebar items only provide an en translation, but the other Testing items include full locale translations. This will leave these labels untranslated (or inconsistent) in non-English locales. Please add the missing locale translations (matching the existing set) or follow the established pattern for this section.

Suggested change
translations: {
en: 'Advanced testing scenarios',
},
slug: 'testing/advanced-scenarios',
},
{
label: 'Testing in CI/CD pipelines',
translations: {
en: 'Testing in CI/CD pipelines',
translations: {
da: 'Avancerede testscenarier',
de: 'Erweiterte Testszenarien',
en: 'Advanced testing scenarios',
es: 'Escenarios de pruebas avanzadas',
fr: 'Scénarios de test avancés',
hi: 'उन्नत परीक्षण परिदृश्य',
id: 'Skenario pengujian lanjutan',
it: 'Scenario di test avanzati',
ja: '高度なテストシナリオ',
ko: '고급 테스트 시나리오',
pt: 'Cenários de teste avançados',
'pt-BR': 'Cenários de teste avançados',
'pt-PT': 'Cenários de teste avançados',
ru: 'Расширенные сценарии тестирования',
tr: 'Gelişmiş test senaryoları',
uk: 'Розширені сценарії тестування',
'zh-CN': '高级测试场景',
},
slug: 'testing/advanced-scenarios',
},
{
label: 'Testing in CI/CD pipelines',
translations: {
da: 'Test i CI/CD-pipelines',
de: 'Tests in CI/CD-Pipelines',
en: 'Testing in CI/CD pipelines',
es: 'Pruebas en canalizaciones CI/CD',
fr: 'Tests dans les pipelines CI/CD',
hi: 'CI/CD पाइपलाइनों में परीक्षण',
id: 'Pengujian di pipeline CI/CD',
it: 'Test nelle pipeline CI/CD',
ja: 'CI/CD パイプラインでのテスト',
ko: 'CI/CD 파이프라인에서의 테스트',
pt: 'Testes em pipelines de CI/CD',
'pt-BR': 'Testes em pipelines de CI/CD',
'pt-PT': 'Testes em pipelines de CI/CD',
ru: 'Тестирование в конвейерах CI/CD',
tr: 'CI/CD ardışık düzenlerinde test',
uk: 'Тестування в конвеєрах CI/CD',
'zh-CN': '在 CI/CD 流水线中的测试',

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,313 @@
---
title: Testing in CI/CD pipelines
description: Learn how to run Aspire integration tests reliably in CI/CD environments including GitHub Actions and Azure DevOps, including timeout configuration, Azure authentication, and container requirements.
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frontmatter description repeats “including” twice (“...including GitHub Actions and Azure DevOps, including ...”). Consider rephrasing to avoid the duplication.

Suggested change
description: Learn how to run Aspire integration tests reliably in CI/CD environments including GitHub Actions and Azure DevOps, including timeout configuration, Azure authentication, and container requirements.
description: Learn how to run Aspire integration tests reliably in CI/CD environments, such as GitHub Actions and Azure DevOps, covering timeout configuration, Azure authentication, and container requirements.

Copilot uses AI. Check for mistakes.

Aspire integration tests typically start containers (databases, caches, and other services) as part of the test run. Your CI environment must have a container runtime available.

- **GitHub Actions**: Docker is available by default on `ubuntu-*`, `windows-*`, and `macos-*` runners.
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The statement that Docker is available by default on GitHub Actions macos-* runners is inaccurate; GitHub-hosted macOS runners don’t provide a Docker Engine suitable for running Linux containers (the common case for Aspire test containers). Recommend updating this to steer users to ubuntu-* runners (and clarify Windows/macOS limitations).

Suggested change
- **GitHub Actions**: Docker is available by default on `ubuntu-*`, `windows-*`, and `macos-*` runners.
- **GitHub Actions**: For Linux-based Aspire test containers, use `ubuntu-*` runners, which have Docker available by default. GitHub-hosted `windows-*` and `macos-*` runners do not provide a Docker Engine suitable for running Linux containers; use self-hosted runners with a configured container runtime if you must target those operating systems.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Discord Feedback] Testing documentation gaps

2 participants