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

Fix or add more details about some MSTest rules #41885

Merged
merged 3 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0008.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ Methods marked with `[TestInitialize]` should follow the following layout to be
- it should not take any parameter
- return type should be `void`, `Task` or `ValueTask`

The type declaring these methods should also respect the following rules:
Evangelink marked this conversation as resolved.
Show resolved Hide resolved

- the type should be a class
Evangelink marked this conversation as resolved.
Show resolved Hide resolved
- the class should be `public` or `internal` (if the test project is using the `[DiscoverInternals]` attribute)
Evangelink marked this conversation as resolved.
Show resolved Hide resolved
- the class should not be `static`
Evangelink marked this conversation as resolved.
Show resolved Hide resolved
- if the class is sealed, it should be marked with `[TestClass]` (or a derived attribute)
Evangelink marked this conversation as resolved.
Show resolved Hide resolved

## How to fix violations

Ensure that the method matches the layout described above.
Expand Down
7 changes: 7 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0009.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ Methods marked with `[TestCleanup]` should follow the following layout to be val
- it should not take any parameter
- return type should be `void`, `Task` or `ValueTask`

The type declaring these methods should also respect the following rules:

- the type should be a class
- the class should be `public` or `internal` (if the test project is using the `[DiscoverInternals]` attribute)
- the class should not be `static`
- if the class is sealed, it should be marked with `[TestClass]` (or a derived attribute)

## How to fix violations

Ensure that the method matches the layout described above.
Expand Down
8 changes: 8 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0010.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ Methods marked with `[ClassInitialize]` should follow the following layout to be
- it should take one parameter of type `TestContext`
- return type should be `void`, `Task` or `ValueTask`

The type declaring these methods should also respect the following rules:

- the type should be a class
- the class should be `public` or `internal` (if the test project is using the `[DiscoverInternals]` attribute)
- the class should not be `static`
- the class should not be generic
- if the class is sealed, it should be marked with `[TestClass]` (or a derived attribute)

## How to fix violations

Ensure that the method matches the layout described above.
Expand Down
8 changes: 8 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0011.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ Methods marked with `[ClassCleanup]` should follow the following layout to be va
- it should not take any parameter
- return type should be `void`, `Task` or `ValueTask`

The type declaring these methods should also respect the following rules:

- the type should be a class
- the class should be `public` or `internal` (if the test project is using the `[DiscoverInternals]` attribute)
- the class should not be `static`
- the class should not be generic
- if the class is sealed, it should be marked with `[TestClass]` (or a derived attribute)

## How to fix violations

Ensure that the method matches the layout described above.
Expand Down
8 changes: 8 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0012.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ Methods marked with `[AssemblyInitialize]` should follow the following layout to
- it should take one parameter of type `TestContext`
- return type should be `void`, `Task` or `ValueTask`

The type declaring these methods should also respect the following rules:

- the type should be a class
- the class should be `public` or `internal` (if the test project is using the `[DiscoverInternals]` attribute)
- the class should not be `static`
- the class should not be generic
- if the class is sealed, it should be marked with `[TestClass]` (or a derived attribute)

## How to fix violations

Ensure that the method matches the layout described above.
Expand Down
8 changes: 8 additions & 0 deletions docs/core/testing/mstest-analyzers/mstest0013.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ Methods marked with `[AssemblyCleanup]` should follow the following layout to be
- it should not take any parameter
- return type should be `void`, `Task` or `ValueTask`

The type declaring these methods should also respect the following rules:

- the type should be a class
- the class should be `public` or `internal` (if the test project is using the `[DiscoverInternals]` attribute)
- the class should not be `static`
- the class should not be generic
- if the class is sealed, it should be marked with `[TestClass]` (or a derived attribute)

## How to fix violations

Ensure that the method matches the layout described above.
Expand Down
4 changes: 2 additions & 2 deletions docs/core/testing/mstest-analyzers/mstest0029.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ ms.author: enjieid

## Cause

A Public method should be a test method.
A `public` method should be a test method.

## Rule description

A Public method should be a test method (marked with `[TestMethod]`).
A `public` method of a class marked with `[TestClass]` should be a test method (marked with `[TestMethod]`). The rule ignores methods that are marked with `[TestInitialize]`, or `[TestCleanup]` attributes.

## How to fix violations

Expand Down
2 changes: 1 addition & 1 deletion docs/core/testing/mstest-analyzers/mstest0030.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ms.author: enjieid

## Cause

Type contaning `[TestMethod]` should be marked with `[TestClass]`, otherwise the test method will be silently ignored.
Type containing `[TestMethod]` should be marked with `[TestClass]`, otherwise the test method will be silently ignored.

## Rule description

Expand Down
Loading