Skip to content

Latest commit

 

History

History
102 lines (91 loc) · 11.8 KB

NUnit-Analyzers.md

File metadata and controls

102 lines (91 loc) · 11.8 KB
uid
nunitanalyzers

Overview of implemented NUnit diagnostics and code fixes

In the tables below we use the following symbols:

  • 🔍 - whether the diagnostic is enabled by default or not
  • 📝 - the severity of the diagnostic
  • 💡 - whether the diagnostic has an associated code fix or not

The severity of a diagnostic can the one of the following (in increasing severity):

  • 💭 - indicates a severity of Hidden
  • ℹ️ - indicates a severity of Info
  • ⚠️ - indicates a severity of Warning
  • ❗ - indicates a severity of Error

Structure Rules (NUnit1001 - )

Rules which enforce structural requirements on the test code.

Id Title 🔍 📝 💡
NUnit1001 The individual arguments provided by a TestCaseAttribute must match the type of the corresponding parameter of the method
NUnit1002 The TestCaseSource should use nameof operator to specify target ⚠️
NUnit1003 The TestCaseAttribute provided too few arguments
NUnit1004 The TestCaseAttribute provided too many arguments
NUnit1005 The type of the value specified via ExpectedResult must match the return type of the method
NUnit1006 ExpectedResult must not be specified when the method returns void
NUnit1007 The method has non-void return type, but no result is expected in ExpectedResult
NUnit1008 Specifying ParallelScope.Self on assembly level has no effect ⚠️
NUnit1009 One may not specify ParallelScope.Children on a non-parameterized test method
NUnit1010 One may not specify ParallelScope.Fixtures on a test method
NUnit1011 The TestCaseSource argument does not specify an existing member
NUnit1012 The async test method must have a non-void return type
NUnit1013 The async test method must have a non-generic Task return type when no result is expected
NUnit1014 The async test method must have a Task<T> return type when a result is expected
NUnit1015 The source type does not implement IEnumerable
NUnit1016 The source type does not have a default constructor
NUnit1017 The specified source is not static
NUnit1018 The number of parameters provided by the TestCaseSource does not match the number of parameters in the target method
NUnit1019 The source specified by the TestCaseSource does not return an IEnumerable or a type that implements IEnumerable
NUnit1020 The TestCaseSource provides parameters to a source - field or property - that expects no parameters
NUnit1021 The ValueSource should use nameof operator to specify target ⚠️
NUnit1022 The specified source is not static
NUnit1023 The target method expects parameters which cannot be supplied by the ValueSource
NUnit1024 The source specified by the ValueSource does not return an IEnumerable or a type that implements IEnumerable
NUnit1025 The ValueSource argument does not specify an existing member
NUnit1026 The test or setup/teardown method is not public
NUnit1027 The test method has parameters, but no arguments are supplied by attributes
NUnit1028 The non-test method is public ℹ️

Assertion Rules (NUnit2001 - )

Rules which improve assertions in the test code.

Id Title 🔍 📝 💡
NUnit2001 Consider using Assert.That(expr, Is.False) instead of Assert.False(expr) ℹ️
NUnit2002 Consider using Assert.That(expr, Is.False) instead of Assert.IsFalse(expr) ℹ️
NUnit2003 Consider using Assert.That(expr, Is.True) instead of Assert.IsTrue(expr) ℹ️
NUnit2004 Consider using Assert.That(expr, Is.True) instead of Assert.True(expr) ℹ️
NUnit2005 Consider using Assert.That(actual, Is.EqualTo(expected)) instead of Assert.AreEqual(expected, actual) ⚠️
NUnit2006 Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of Assert.AreNotEqual(expected, actual) ⚠️
NUnit2007 The actual value should not be a constant ⚠️
NUnit2008 Incorrect IgnoreCase usage ⚠️
NUnit2009 The same value has been provided as both the actual and the expected argument ⚠️
NUnit2010 Use EqualConstraint for better assertion messages in case of failure ℹ️
NUnit2011 Use ContainsConstraint for better assertion messages in case of failure ℹ️
NUnit2012 Use StartsWithConstraint for better assertion messages in case of failure ℹ️
NUnit2013 Use EndsWithConstraint for better assertion messages in case of failure ℹ️
NUnit2014 Use SomeItemsConstraint for better assertion messages in case of failure ℹ️
NUnit2015 Consider using Assert.That(actual, Is.SameAs(expected)) instead of Assert.AreSame(expected, actual) ⚠️
NUnit2016 Consider using Assert.That(expr, Is.Null) instead of Assert.Null(expr) ℹ️
NUnit2017 Consider using Assert.That(expr, Is.Null) instead of Assert.IsNull(expr) ℹ️
NUnit2018 Consider using Assert.That(expr, Is.Not.Null) instead of Assert.NotNull(expr) ℹ️
NUnit2019 Consider using Assert.That(expr, Is.Not.Null) instead of Assert.IsNotNull(expr) ℹ️
NUnit2020 Incompatible types for SameAs constraint
NUnit2021 Incompatible types for EqualTo constraint
NUnit2022 Missing property required for constraint
NUnit2023 Invalid NullConstraint usage
NUnit2024 Wrong actual type used with String Constraint
NUnit2025 Wrong actual type used with ContainsConstraint
NUnit2026 Wrong actual type used with the SomeItemsConstraint with EqualConstraint
NUnit2027 Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of Assert.Greater(actual, expected) ℹ️
NUnit2028 Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of Assert.GreaterOrEqual(actual, expected) ℹ️
NUnit2029 Consider using Assert.That(actual, Is.LessThan(expected)) instead of Assert.Less(actual, expected) ℹ️
NUnit2030 Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of Assert.LessOrEqual(actual, expected) ℹ️
NUnit2031 Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of Assert.AreNotSame(expected, actual) ⚠️
NUnit2032 Consider using Assert.That(expr, Is.Zero) instead of Assert.Zero(expr) ℹ️
NUnit2033 Consider using Assert.That(expr, Is.Not.Zero) instead of Assert.NotZero(expr) ℹ️
NUnit2034 Consider using Assert.That(expr, Is.NaN) instead of Assert.IsNaN(expr) ℹ️
NUnit2035 Consider using Assert.That(collection, Is.Empty) instead of Assert.IsEmpty(collection) ℹ️
NUnit2036 Consider using Assert.That(collection, Is.Not.Empty) instead of Assert.IsNotEmpty(collection) ℹ️
NUnit2037 Consider using Assert.That(collection, Does.Contain(instance)) instead of Assert.Contains(instance, collection) ℹ️
NUnit2038 Consider using Assert.That(actual, Is.InstanceOf(expected)) instead of Assert.IsInstanceOf(expected, actual) ℹ️
NUnit2039 Consider using Assert.That(actual, Is.Not.InstanceOf(expected)) instead of Assert.IsNotInstanceOf(expected, actual) ℹ️
NUnit2040 Non-reference types for SameAs constraint
NUnit2041 Incompatible types for comparison constraint
NUnit2042 Comparison constraint on object ℹ️