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

Test classes should have test methods #2374

Closed
Evangelink opened this issue Feb 19, 2024 · 4 comments
Closed

Test classes should have test methods #2374

Evangelink opened this issue Feb 19, 2024 · 4 comments

Comments

@Evangelink
Copy link
Member

Summary

Enabled by default: true
Default severity: Info
Title: Test classes should have test methods

When a non-abstract or static type is marked with [TestClass] (or any descendant), it should contain at least one test method.

@AliveDevil
Copy link

The analyzer should consider Assembly Initializers:

[TestClass]
class GlobalState {
  [AssemblyInitializer]
  static void Init(TestContext context) { … }
  [AssemblyCleanup]
  static void Cleanup() { … }
}

@Evangelink
Copy link
Member Author

Thanks for the feedback! I was considering it through a static class hence the non-static, non-abstract but you are right that not everyone would follow that pattern.

@AliveDevil
Copy link

Ah, so

[TestClass]
static class GlobalState {
 [AssemblyInitializer] …

would work?
If this is the case, the wording "non-abstract or static type […] should contain at least one test method" should not include "static" (or rephrase that it applies to non-abstract and non-static / non (abstract or static)), then the analyzer can be stricter for these types.

@Evangelink
Copy link
Member Author

Just realizing that I already created a ticket for this one here #2236. Will close this one as duplicate and copy your comments.

@Evangelink Evangelink removed this from the 3.4.0 milestone Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants