Skip to content

Comments

.NET: Fix copilot studio integration tests failure#4209

Merged
westey-m merged 1 commit intomicrosoft:feature-xunit3-mtp-upgradefrom
westey-m:fix-copilot-studio-int-test-failure
Feb 24, 2026
Merged

.NET: Fix copilot studio integration tests failure#4209
westey-m merged 1 commit intomicrosoft:feature-xunit3-mtp-upgradefrom
westey-m:fix-copilot-studio-int-test-failure

Conversation

@westey-m
Copy link
Contributor

Motivation and Context

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings February 24, 2026 12:07
@westey-m westey-m merged commit d04228d into microsoft:feature-xunit3-mtp-upgrade Feb 24, 2026
6 checks passed
@github-actions github-actions bot changed the title Fix copilot studio integration tests failure .NET: Fix copilot studio integration tests failure Feb 24, 2026
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

This PR attempts to fix CopilotStudio integration test failures by wrapping the configuration loading in a try-catch block and calling Assert.Skip() when the configuration cannot be loaded. The intent is to gracefully skip tests when CopilotStudio configuration is not available rather than failing with an exception.

Changes:

  • Added try-catch error handling around TestConfiguration.LoadSection<CopilotStudioAgentConfiguration>() call
  • Calls Assert.Skip() with an error message if configuration loading fails
  • Uses null-forgiving operator on config variable after the try-catch block
Comments suppressed due to low confidence (1)

dotnet/tests/CopilotStudio.IntegrationTests/CopilotStudioFixture.cs:41

  • The error message concatenation lacks a space between "Error:" and the exception message. Consider using string interpolation for better readability: Assert.Skip($"CopilotStudio configuration could not be loaded. Error: {ex.Message}");
            Assert.Skip("CopilotStudio configuration could not be loaded. Error:" + ex.Message);

Comment on lines +39 to +42
catch (InvalidOperationException ex)
{
Assert.Skip("CopilotStudio configuration could not be loaded. Error:" + ex.Message);
}
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

Calling Assert.Skip() inside InitializeAsync() won't properly skip tests. When InitializeAsync() is called during fixture initialization (via AgentTests<TAgentFixture>.InitializeAsync()), the skip is triggered before any actual test method runs, which may not be handled correctly by the test framework.

A better approach would be to follow the pattern used in CosmosChatHistoryProviderTests:

  1. Store the configuration loading result in an instance field (e.g., _configLoadFailed or _skipReason)
  2. Don't throw or call Assert.Skip during initialization
  3. Have each test method check this field at the start and skip if needed, OR
  4. Store the skip reason in a public static field that tests can check (similar to AnthropicChatCompletionFixture.SkipReason)

The Cosmos pattern is particularly relevant here since it also handles external dependencies that may not be available. See CosmosChatHistoryProviderTests.SkipIfEmulatorNotAvailable() at line 142-149.

Copilot uses AI. Check for mistakes.
Assert.Skip("CopilotStudio configuration could not be loaded. Error:" + ex.Message);
}

var settings = new CopilotStudioConnectionSettings(config!.TenantId, config.AppClientId)
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

The null-forgiving operator (!) is used after checking for null and potentially calling Assert.Skip. However, since the catch block calls Assert.Skip (which should terminate execution), the config variable will still be null if the exception occurs. If Assert.Skip doesn't properly terminate execution in this context (which is the case when called from InitializeAsync), this will result in a NullReferenceException.

The config variable should not need the null-forgiving operator if the exception handling is properly restructured. After fixing the Assert.Skip issue, consider either: (1) not initializing the agent when config loading fails, or (2) storing the skip state and allowing tests to check it later.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants