Nunit.analyzers
Roslyn analyzers for writing unit tests with NUnit
Install / Use
/learn @nunit/Nunit.analyzersREADME
NUnit Analyzers
This is a suite of analyzers that target the NUnit testing framework. Right now, the code is separate from the NUnit framework, so if you want to try out the analyzers you'll need to download the analyzers separately as a nuget package. In the future the analyzers may be added as part of the NUnit framework package but that hasn't been done yet.
Download
The latest stable release of the NUnit Analyzers is available on NuGet or can be downloaded from GitHub. Note that for Visual Studio 2017 one must use versions below 3.0 - note that these versions are no longer updated, so version 2.10.0 is the last version that works in Visual Studio 2017. Version 3.0 and upwards require Visual Studio 2019 (version 16.3) or newer, these versions also enables supression of compiler errors such as errors arising from nullable reference types.
Prerelease nuget packages can be found on MyGet. Please try out the package and report bugs and feature requests.
Analyzers
The full list of analyzers can be found in the documentation.
Below we give two examples of analyzers. One will look for methods with the [TestCase] attribute and makes sure the argument values are correct for the types of the method parameters along with the ExpectedResult value if it is provided.
The other analyzer looks for classic model assertions (e.g. Assert.AreEqual(), Assert.IsTrue(), etc.). This analyzer contains a fixer that can translate the classic model assertions into constraint model assertions (Assert.That()).
Which version works with Unity Test Framework
Use the following version depending on your project's Unity version:
- Unity 2022.2 or newer: NUnit.Analyzer v3.9.0
- Unity 2021.2 or newer: NUnit.Analyzer v3.3.0
- Unity 2020.2 or newer: NUnit.Analyzer v2.10.0
!NOTE
Unity uses specific versions of Microsoft.CodeAnalysis.CSharp, which means not all analyzer versions work with all Unity versions.
!NOTE
Unity Test Framework is based on NUnit3.5
License
NUnit analyzers are Open Source software and released under the MIT license, which allow the use of the analyzers in free and commercial applications and libraries without restrictions.
Contributing
There are several ways to contribute to this project. One can try things out, report bugs, propose improvements and new functionality, work on issues (especially the issues marked with the labels help wanted and Good First Issue), and in general join in the conversations. See Contributing for more information.
This project has adopted the Code of Conduct from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4. See the Code of Conduct for more information.
Contributors
NUnit.Analyzers was created by Jason Bock. A complete list of contributors can be found on the GitHub contributors page.
Related Skills
docs-writer
99.5k`docs-writer` skill instructions As an expert technical writer and editor for the Gemini CLI project, you produce accurate, clear, and consistent documentation. When asked to write, edit, or revie
model-usage
341.0kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
project-overview
FlightPHP Skeleton Project Instructions This document provides guidelines and best practices for structuring and developing a project using the FlightPHP framework. Instructions for AI Coding A
ddd
Guía de Principios DDD para el Proyecto > 📚 Documento Complementario : Este documento define los principios y reglas de DDD. Para ver templates de código, ejemplos detallados y guías paso
