nunit.analyzers
nunit.analyzers copied to clipboard
Roslyn analyzers for writing unit tests with NUnit
Operators are a bit confusing in NUnit. Personally I don't fully understand how they work. I've seen multiple times that constraint `Is.Not.Null.Or.Empty` is used to validate that string is not...
See https://github.com/nunit/nunit/issues/3633 . Probably should have error severity.
This has come up more than once, though I'm only able to find this one right now: https://github.com/nunit/nunit/issues/3531#issuecomment-624206302 There should be a warning that code like this is misleading. Attribute...
Consider the following example: ```csharp namespace BadNUnitExamples { using NUnit.Framework; class NUnitTestCaseDataResult { [TestCase(1, 1, ExpectedResult = 0, TestName = "Test")] [TestCase(2, 2, ExpectedResult = 0, TestName = "Test")] public...
# Description: A class marked with `[TestFixture]` must have all of their constructors as `public` as well as any methods marked with `[Test]` or `[TestCase]`. # Example: ``` [TestFixture] internal...
# Description Based on discussion from here: https://github.com/nunit/docs/issues/149 If a method is marked with `[TearDown]`, no assertion calls from the `Assert` class should be allowed. # Example ```csharp [TearDown] public...
# Description: If a class is marked with `[TestFixture]`, it must have at least one method marked with `[Test]` or `[TestCase]`. # Example: ``` [TestFixture] public class MyTests { }...
Probably default disbled making it opt-in. Nice convenience for refactoring if nothing else.
For catching mistakes like: ```cs [Test] public void SomeTest() { // Assert.AreEqual(...); } ``` Perhaps very common. Don't warn if `[Ignore]` or `[Explicit]`
I have found it to be nice to have classes like: ```cs internal static class NUNIT17TestCaseSourceIsMissing { public const string DiagnosticId = "NUNIT_17"; internal static readonly DiagnosticDescriptor Descriptor = new...