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

undocumented/implicit [TestClass]/abstract requirement for MSTEST0008 (an maybe possible others) #3323

Closed
LukasGelke opened this issue Jul 24, 2024 · 2 comments · Fixed by #3391

Comments

@LukasGelke
Copy link

Describe the bug

Description states:

Warning (active)	MSTEST0008	Methods marked with [TestInitialize] should follow the following layout to be valid:
- be 'public' 
- not be 'static'
- not be generic nor defined on a generic class
- not be 'abstract'
- not take any parameter
- return type should be 'void', 'Task' or 'ValueTask'
- not be 'async void'
- not be a special method (finalizer, operator...)

Steps To Reproduce

public sealed class MyExample1Test
{
  [TestInitialize]
  public void Init() { } // MSTEST0008
}

[TestClass]
public sealed class MyExample2Test
{
  [TestInitialize]
  public void Init() { } // allowed, because [TestClass]
}

public abstract class MyExample3Test
{
  [TestInitialize]
  public void Init() { } // allowed, because abstract
}

Expected behavior

Diagnostic Message should include (a) line(s) like:

- be defined in a `abstract` class or a class with a `TestClassAttribute`

Actual behavior

no mention of abstract/ TestClassAttribute leads to confusion

Additional context

@Evangelink
Copy link
Member

Hi @LukasGelke,

Thanks for the feedback! We did a couple of fixes and it seems we haven't always done the follow-up for the docs.

@Evangelink Evangelink added Help-Wanted The issue is up-for-grabs, and can be claimed by commenting Area: Documentation and removed Needs: Triage 🔍 labels Jul 24, 2024
@Evangelink Evangelink added this to the MSTest 3.6 / Platform 1.4 milestone Jul 24, 2024
@engyebrahim
Copy link
Member

engyebrahim commented Aug 1, 2024

Hello, the rule updated rule should be:

  • be defined in any class type or a sealed class marked with TestClassAttribute

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Help-Wanted The issue is up-for-grabs, and can be claimed by commenting label Aug 2, 2024
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.

3 participants