You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Documentation/Diagnostics/PH2159.md
+17-21Lines changed: 17 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,56 +12,49 @@
12
12
13
13
## Introduction
14
14
15
-
Test methods with multiple DataRow attributes may benefit from using combinatorial testing instead. Combinatorial testing allows you to test multiple combinations of parameter values more efficiently using the `Combinatorial.MSTest` package.
15
+
Test methods with a single parameter and multiple DataRow attributes can be simplified using CombinatorialValues from the `Combinatorial.MSTest` package. This makes the test more maintainable and concise when you have many values to test for a single parameter.
16
16
17
17
## How to solve
18
18
19
-
Consider refactoring your test method to use combinatorial testing with the `Combinatorial.MSTest` package. This can make your tests more maintainable when you have many parameter combinations.
19
+
Consider refactoring your test method to use CombinatorialValues with the `Combinatorial.MSTest` package. This is particularly beneficial for single-parameter methods with many different test values.
**Note**: The `Combinatorial.MSTest` package may not work with all parameter combinations and has limitations when mixing combinatorial and non-combinatorial parameters. Evaluate whether the refactoring is appropriate for your specific test case.
64
-
65
58
## Configuration
66
59
67
60
This analyzer is disabled by default. To enable it, add the following to your .editorconfig:
@@ -70,6 +63,9 @@ This analyzer is disabled by default. To enable it, add the following to your .e
70
63
dotnet_diagnostic.PH2159.severity = suggestion
71
64
```
72
65
73
-
The analyzer triggers when a test method has 4 or more DataRow attributes.
66
+
The analyzer triggers when:
67
+
- A test method has exactly 1 parameter
68
+
- The method has 4 or more DataRow attributes
69
+
- All DataRow attributes have exactly 1 argument each
74
70
75
71
The general ways of [suppressing](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/suppress-warnings) diagnostics apply.
privateconststringTitle=@"Consider using combinatorial testing";
15
-
publicconststringMessageFormat=@"Consider using combinatorial testing instead of multiple DataRow attributes. This method has {0} DataRow attributes.";
16
-
privateconststringDescription=@"Methods with multiple DataRow attributes may benefit from combinatorial testing using the Combinatorial.MSTest package for better maintainability.";
15
+
publicconststringMessageFormat=@"Consider using CombinatorialValues instead of {0} DataRow attributes for this single-parameter method.";
16
+
privateconststringDescription=@"Methods with a single parameter and multiple DataRow attributes can be simplified using CombinatorialValues from the Combinatorial.MSTest package.";
0 commit comments