Skip to content

Move ErrorUtilities_Tests to Assumed_Tests - #14141

Merged
JanProvaznik merged 1 commit into
dotnet:mainfrom
DustinCampbell:remove-errorutilities-tests
Jun 24, 2026
Merged

Move ErrorUtilities_Tests to Assumed_Tests#14141
JanProvaznik merged 1 commit into
dotnet:mainfrom
DustinCampbell:remove-errorutilities-tests

Conversation

@DustinCampbell

Copy link
Copy Markdown
Member

ErrorUtilities_Tests.cs tested Assumed.True APIs, not ErrorUtilities. Consolidate these tests into Assumed_Tests.cs in Framework.UnitTests, updating from xUnit Assert to Shouldly and adding coverage for:

  • True(bool, string?) with a non-null message (both passing and failing)
  • Lazy evaluation of the TrueInterpolatedStringHandler: verifies the interpolated string is not formatted when the condition is true, is formatted when false, and formats multiple args correctly

Remove ErrorUtilities_Tests.cs and its links from Build.UnitTests, Tasks.UnitTests, and Utilities.UnitTests.

ErrorUtilities_Tests.cs tested Assumed.True APIs, not ErrorUtilities.
Consolidate these tests into Assumed_Tests.cs in Framework.UnitTests,
updating from xUnit Assert to Shouldly and adding coverage for:
- True(bool, string?) with a non-null message (both passing and failing)
- Lazy evaluation of the TrueInterpolatedStringHandler: verifies the
  interpolated string is not formatted when the condition is true, is
  formatted when false, and formats multiple args correctly

Remove ErrorUtilities_Tests.cs and its <Compile> links from
Build.UnitTests, Tasks.UnitTests, and Utilities.UnitTests.
Copilot AI review requested due to automatic review settings June 23, 2026 18:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 consolidates tests that were validating Assumed.True behavior (including interpolated string handler laziness) by moving them out of ErrorUtilities_Tests.cs into Framework.UnitTests’s Assumed_Tests.cs, and removes the now-misleading shared test file and its compile links from other test projects.

Changes:

  • Move/merge Assumed.True-focused tests into src/Framework.UnitTests/Assumed_Tests.cs, updating assertions to Shouldly and expanding interpolated-string-handler coverage.
  • Delete src/Shared/UnitTests/ErrorUtilities_Tests.cs (which wasn’t testing ErrorUtilities) and remove <Compile Include=...> links from multiple unit test projects.
  • Keep the shared unit test projects clean by avoiding redundant/incorrectly-scoped shared test files.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Framework.UnitTests/Assumed_Tests.cs Adds/hosts the migrated Assumed.True tests and new interpolated-string-handler laziness scenarios.
src/Shared/UnitTests/ErrorUtilities_Tests.cs Removes the miscategorized shared test file.
src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj Removes the shared compile include for the deleted test file.
src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj Removes the shared compile include for the deleted test file.
src/Utilities.UnitTests/Microsoft.Build.Utilities.UnitTests.csproj Removes the shared compile include for the deleted test file.
Comments suppressed due to low confidence (1)

src/Framework.UnitTests/Assumed_Tests.cs:106

  • PR description says to add coverage for Assumed.True(bool, string?) with a non-null message in both passing and failing cases. The passing case was added, but there's no test verifying the custom message is included in the thrown InternalErrorException when the condition is false (this coverage was previously in ErrorUtilities_Tests).
    [Fact]
    public void True_DoesNotThrow_WithMessage_WhenTrue()
    {
        Assumed.True(true, "msbuild rules");
    }

    [Fact]
    public void True_Throws_WhenFalse()
    {
        Should.Throw<InternalErrorException>(() => Assumed.True(false));
    }

@JanProvaznik
JanProvaznik merged commit 104b0f7 into dotnet:main Jun 24, 2026
20 of 21 checks passed
@DustinCampbell
DustinCampbell deleted the remove-errorutilities-tests branch June 24, 2026 16:20
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.

4 participants