File tree Expand file tree Collapse file tree 8 files changed +49
-3
lines changed
docs/core/testing/mstest-analyzers Expand file tree Collapse file tree 8 files changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,13 @@ Methods marked with `[TestInitialize]` should follow the following layout to be
40
40
- it should not take any parameter
41
41
- return type should be ` void ` , ` Task ` or ` ValueTask `
42
42
43
+ The type declaring these methods should also respect the following rules:
44
+
45
+ - the type should be a class
46
+ - the class should be ` public ` or ` internal ` (if the test project is using the ` [DiscoverInternals] ` attribute)
47
+ - the class should not be ` static `
48
+ - if the class is sealed, it should be marked with ` [TestClass] ` (or a derived attribute)
49
+
43
50
## How to fix violations
44
51
45
52
Ensure that the method matches the layout described above.
Original file line number Diff line number Diff line change @@ -40,6 +40,13 @@ Methods marked with `[TestCleanup]` should follow the following layout to be val
40
40
- it should not take any parameter
41
41
- return type should be ` void ` , ` Task ` or ` ValueTask `
42
42
43
+ The type declaring these methods should also respect the following rules:
44
+
45
+ - the type should be a class
46
+ - the class should be ` public ` or ` internal ` (if the test project is using the ` [DiscoverInternals] ` attribute)
47
+ - the class should not be ` static `
48
+ - if the class is sealed, it should be marked with ` [TestClass] ` (or a derived attribute)
49
+
43
50
## How to fix violations
44
51
45
52
Ensure that the method matches the layout described above.
Original file line number Diff line number Diff line change @@ -40,6 +40,14 @@ Methods marked with `[ClassInitialize]` should follow the following layout to be
40
40
- it should take one parameter of type ` TestContext `
41
41
- return type should be ` void ` , ` Task ` or ` ValueTask `
42
42
43
+ The type declaring these methods should also respect the following rules:
44
+
45
+ - the type should be a class
46
+ - the class should be ` public ` or ` internal ` (if the test project is using the ` [DiscoverInternals] ` attribute)
47
+ - the class should not be ` static `
48
+ - the class should not be generic
49
+ - if the class is sealed, it should be marked with ` [TestClass] ` (or a derived attribute)
50
+
43
51
## How to fix violations
44
52
45
53
Ensure that the method matches the layout described above.
Original file line number Diff line number Diff line change @@ -40,6 +40,14 @@ Methods marked with `[ClassCleanup]` should follow the following layout to be va
40
40
- it should not take any parameter
41
41
- return type should be ` void ` , ` Task ` or ` ValueTask `
42
42
43
+ The type declaring these methods should also respect the following rules:
44
+
45
+ - the type should be a class
46
+ - the class should be ` public ` or ` internal ` (if the test project is using the ` [DiscoverInternals] ` attribute)
47
+ - the class should not be ` static `
48
+ - the class should not be generic
49
+ - if the class is sealed, it should be marked with ` [TestClass] ` (or a derived attribute)
50
+
43
51
## How to fix violations
44
52
45
53
Ensure that the method matches the layout described above.
Original file line number Diff line number Diff line change @@ -40,6 +40,14 @@ Methods marked with `[AssemblyInitialize]` should follow the following layout to
40
40
- it should take one parameter of type ` TestContext `
41
41
- return type should be ` void ` , ` Task ` or ` ValueTask `
42
42
43
+ The type declaring these methods should also respect the following rules:
44
+
45
+ - the type should be a class
46
+ - the class should be ` public ` or ` internal ` (if the test project is using the ` [DiscoverInternals] ` attribute)
47
+ - the class should not be ` static `
48
+ - the class should not be generic
49
+ - if the class is sealed, it should be marked with ` [TestClass] ` (or a derived attribute)
50
+
43
51
## How to fix violations
44
52
45
53
Ensure that the method matches the layout described above.
Original file line number Diff line number Diff line change @@ -40,6 +40,14 @@ Methods marked with `[AssemblyCleanup]` should follow the following layout to be
40
40
- it should not take any parameter
41
41
- return type should be ` void ` , ` Task ` or ` ValueTask `
42
42
43
+ The type declaring these methods should also respect the following rules:
44
+
45
+ - the type should be a class
46
+ - the class should be ` public ` or ` internal ` (if the test project is using the ` [DiscoverInternals] ` attribute)
47
+ - the class should not be ` static `
48
+ - the class should not be generic
49
+ - if the class is sealed, it should be marked with ` [TestClass] ` (or a derived attribute)
50
+
43
51
## How to fix violations
44
52
45
53
Ensure that the method matches the layout described above.
Original file line number Diff line number Diff line change @@ -25,11 +25,11 @@ ms.author: enjieid
25
25
26
26
## Cause
27
27
28
- A Public method should be a test method.
28
+ A ` public ` method should be a test method.
29
29
30
30
## Rule description
31
31
32
- A Public method should be a test method (marked with ` [TestMethod] ` ).
32
+ 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 .
33
33
34
34
## How to fix violations
35
35
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ ms.author: enjieid
25
25
26
26
## Cause
27
27
28
- Type contaning ` [TestMethod] ` should be marked with ` [TestClass] ` , otherwise the test method will be silently ignored.
28
+ Type containing ` [TestMethod] ` should be marked with ` [TestClass] ` , otherwise the test method will be silently ignored.
29
29
30
30
## Rule description
31
31
You can’t perform that action at this time.
0 commit comments