Skip to content

xUnit1024 fired even if one of the overloads is a private helper method #1361

@jasonmalinowski

Description

@jasonmalinowski

If I install xunit.analyzers 0.5.0 and write:

    public class X
    {
        [Fact]
        public void Test()
        {
            Test(42, 42);
        }

        private void Test(int x, int y)
        {
            Assert.Equal(x, y);
        }
    }

xUnit1024 ('test method has same name as another method') is fired on the method, despite that the second method isn't a test. If I disable analyzers, build this library, and run it under the console runner, I do see the test is ran:

xUnit.net Console Runner (64-bit .NET 4.0.30319.42000)
  Discovering: TestXunit
  Discovered:  TestXunit
  Starting:    TestXunit
  Finished:    TestXunit
=== TEST EXECUTION SUMMARY ===
   TestXunit  Total: 1, Errors: 0, Failed: 0, Skipped: 0, Time: 0.138s

It seems here the analyzer is being overly aggressive and I suspect shouldn't be flagging in this case.

Happy to contribute the fix if somebody who knows how this Should Work™ can confirm my gut.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions