docs/articles/nunit-analyzers/NUnit1028.md
| Topic | Value |
|---|---|
| Id | NUnit1028 |
| Severity | Info |
| Enabled | True |
| Category | Structure |
| Code | NonTestMethodAccessibilityLevelAnalyzer |
A fixture should not contain any public non-test methods.
There are two exceptions: A public constructor and an IDisposable.Dispose method implementation.
A fixture should be self-contained and not have methods callable by other classes.
If the methods are purely for this class, mark them as 'private'. If the methods are used by other classes move these methods to a separate class used by the relevant test fixtures.
<!-- start generated config severity -->Configure the severity per project, for more info see MSDN.
# NUnit1028: The non-test method is public
dotnet_diagnostic.NUnit1028.severity = chosenSeverity
where chosenSeverity can be one of none, silent, suggestion, warning, or error.
#pragma warning disable NUnit1028 // The non-test method is public
Code violating the rule here
#pragma warning restore NUnit1028 // The non-test method is public
Or put this at the top of the file to disable all instances.
#pragma warning disable NUnit1028 // The non-test method is public
[SuppressMessage][System.Diagnostics.CodeAnalysis.SuppressMessage("Structure",
"NUnit1028:The non-test method is public",
Justification = "Reason...")]