Skip to content

Commit 36fc6f0

Browse files
Copilotrjmurillo
andauthored
Fix duplicate test cases causing xUnit to skip tests (#456)
## Problem When running tests with `dotnet test --settings ./build/targets/tests/test.runsettings`, xUnit was showing duplicate test case warnings and skipping tests: ``` [xUnit.net] Skipping test case with duplicate ID '563efcecb5eb6234578552365c961e96245c2c02' [xUnit.net] Skipping test case with duplicate ID '61d653fcc9ca0f6aacdb2092a69413258d3d7792' [xUnit.net] Skipping test case with duplicate ID '25a082fbf19ca8396f4c22db48a7c3f9937a65ae' [xUnit.net] Skipping test case with duplicate ID '0b16ad785c3c66c94e28e8b5569b212a216a6fc2' ``` ## Root Cause The `CallbackSignatureShouldMatchMockedMethodCodeFixTests.TestData()` method contained duplicate test cases on lines 95-102: ```csharp [ """new Mock<IFoo>().Setup(m => m.Do((long)42)).Returns((long bar) => true);""", """new Mock<IFoo>().Setup(m => m.Do((long)42)).Returns((long bar) => true);""", ], [ """new Mock<IFoo>().Setup(m => m.Do((long)42)).Returns((long bar) => true);""", // DUPLICATE """new Mock<IFoo>().Setup(m => m.Do((long)42)).Returns((long bar) => true);""", // DUPLICATE ], ``` When combined with the `.WithNamespaces().WithMoqReferenceAssemblyGroups()` extension methods that multiply each test case by: - Namespace variations (empty string and "namespace MyNamespace;") - Moq versions (Net80WithOldMoq and Net80WithNewMoq) This created 4 identical test case IDs, causing xUnit to skip the duplicates. ## Solution Removed one of the duplicate test case entries (lines 99-102), keeping only the necessary test case. ## Verification ✅ **Before fix:** 4 duplicate test case warnings ✅ **After fix:** No duplicate warnings, all 896 tests pass ✅ **Minimal change:** Only 4 lines removed, 0 lines added ✅ **Build and test successful with pedantic mode** Fixes #455. --- 💡 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](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rjmurillo <6811113+rjmurillo@users.noreply.github.com>
1 parent b758db1 commit 36fc6f0

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

tests/Moq.Analyzers.Test/CallbackSignatureShouldMatchMockedMethodCodeFixTests.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ public static IEnumerable<object[]> TestData()
9696
"""new Mock<IFoo>().Setup(m => m.Do((long)42)).Returns((long bar) => true);""",
9797
"""new Mock<IFoo>().Setup(m => m.Do((long)42)).Returns((long bar) => true);""",
9898
],
99-
[
100-
"""new Mock<IFoo>().Setup(m => m.Do((long)42)).Returns((long bar) => true);""",
101-
"""new Mock<IFoo>().Setup(m => m.Do((long)42)).Returns((long bar) => true);""",
102-
],
10399
[
104100
"""new Mock<IFoo>().Setup(m => m.Do(42)).Returns((object? bar) => true);""",
105101
"""new Mock<IFoo>().Setup(m => m.Do(42)).Returns((object? bar) => true);""",

0 commit comments

Comments
 (0)