Search Results for

    NUnit documentation

    Write tests you can trust, for any .NET code

    NUnit is the open-source unit-testing framework for .NET. Write a test in a few lines, get warnings about mistakes as you type from the NUnit Analyzers, run it with many sets of data, and run it anywhere: in Visual Studio, Rider, VS Code, on the command line or in your build pipeline.

    Write your first test Install NUnit What's new in NUnit 5

    Popular: Test with many inputs Checking results Preparing and cleaning up Tests that depend on each other Flaky tests Running tests in parallel Microsoft.Testing.Platform Upgrading to NUnit 5 Analyzer warnings

    CalculatorTests.cs
    using NUnit.Framework;
    public class CalculatorTests
    {
        [TestCase(2, 3, 5)]
        [TestCase(-1, 1, 0)]
        public void Add_ReturnsSum(int a, int b, int expected)
        {
            var result = new Calculator().Add(a, b);
            Assert.That(result, Is.EqualTo(expected));
        }
    }

    Writing tests

    From a single test to tests that run with hundreds of inputs.

    • Ordinary tests
    • Preparing and cleaning up
    • Data driven tests
    • Automating tests
    • Checking several things at once
    • Tests that depend on other tests
    • Flaky and slow tests
    • Organizing and selecting tests

    Reference

    • Attributes
    • Assertions overview
    • Fluent assertions (Assert.That)
    • Classic assertions
    • Special assertions
    • Assumptions
    • Warnings
    • TestContext
    • Analyzer rules

    Getting started

    Create a test project in the tool you already use, or add NUnit to an existing one.

    • In Visual Studio
    • In Visual Studio Code
    • In Rider
    • From the command line
    • In an existing project
    • Pre-release and developer builds
    • Samples

    News

    Release notes for NUnit and all its tools.

    • What's new in NUnit 5
    • Upgrading to NUnit 5
    • NUnit framework
    • Test adapter
    • NUnit Analyzers
    • Console and engine

    Run anywhere

    Run your tests in the IDE, on the command line or in your build.

    • Visual Studio, Rider and dotnet test
    • Running with Microsoft.Testing.Platform
    • Configuring with .runsettings
    • Command line console
    • Self-running test programs
    • Choosing which tests to run
    • In a GUI with TestCentric

    NUnit Tech

    How NUnit and its tools work under the hood.

    • NUnit Analyzers
    • The NUnit Engine
    • Supported .NET versions
    • Adapter and engine compatibility
    • Parallel test execution
    • Usage notes
    • Test result file format
    • API reference

    Articles

    Practical guides and deeper reading.

    • Known problems and workarounds
    • Trace and debug output
    • Troubleshooting the test adapter
    • More resources

    Developer info

    For contributors to the NUnit projects.

    • The teams
    • Team practices
    • Coding standards
    • XML documentation
    • Contributions
    • Issue tracking
    • Specifications
    • NUnit internals
    • Packaging

    Advanced

    Make NUnit do more than it does out of the box.

    • Extending NUnit
    • Custom constraints
    • Custom attributes
    • Action attributes
    • Execution hooks
    • Engine extensions

    Archive

    Documentation for older versions and for tools that are no longer maintained.

    • NUnit 2.x documentation
    • Migrating to NUnit 4
    • Breaking changes up to NUnit 4.0
    • Upgrading from NUnit 2 and 3
    • Xamarin runners for mobile devices
    • VS Test Generator
    • Everything in the archive

    Questions? Ask in GitHub Discussions · NUnit on GitHub · Help improve these docs · License

    Back to top Generated by DocFX | Copyright (c) 2018- The NUnit Project - Licensed under CC BY-NC-SA 4.0