Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSTEST0030 only warns when first method in class is marked with [TestMethod] #3968

Closed
Malachi-Datacom opened this issue Oct 23, 2024 · 1 comment · Fixed by #3973
Closed

Comments

@Malachi-Datacom
Copy link

Malachi-Datacom commented Oct 23, 2024

Describe the bug

The warning MSTEST0030 only warns when the first method in the class is marked with [TestMethod]. It does not warn if for example there is a [TestInitailize] marked method that comes before a [TestMethod] marked method

Steps To Reproduce

  1. Create solution
  2. Add MsTest unit test project
  3. Add a method Before the default TestMethod1 method as follows
public class DoesNotWarnMsTest0030
{
    [TestInitialize]
    public void Initialize()
    {

    }

    [TestMethod]
    public void TestMethod1()
    {

    }
}

Reproduction here: Malachi-Datacom/MSTEST0030-Bug-Repro

Expected behavior

An info (or modified level) diagnostic should appear on the class for MSTEST0030

Actual behavior

No diagnostic is produced for MSTEST0030

Additional context

It does not seem to matter whether the first method is marked with any attribute (as long as it's not marked with [TestMethod]), it just needs to appear before the first [TestMethod] attribute

@Evangelink
Copy link
Member

Hi @Malachi-Datacom,

Thank you for raising this issue, I confirm there is a bug in our analyzer. We will ship a fix on the next bug fix version (most likely next week).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants