Next-Gen App & Browser Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Want to setup NUnit environment for your first test? In this NUnit tutorial, you will learn to setup a test runner and Selenium WebDriver with Visual Studio for NUnit test case development.

Himanshu Sheth
January 13, 2026
NUnit is a popular open-source unit testing framework for C#. It is ported from the JUnit framework. It is one of the most popular test frameworks used for the development and execution of tests with the .NET language. In this NUnit Testing Tutorial, we look at NUnit setup example of the environment for developing and executing NUnit tests.
NUnit is a popular open-source testing framework for .NET that helps developers write and organize automated tests easily. You can use it for both unit and Selenium-based automation testing in C#.
Setting Up NUnit in Visual Studio
dotnet test
Writing Your First NUnit Test
using NUnit.Framework;
[TestFixture]
public class CalculatorTests {
private Calculator calc;
[SetUp]
public void Setup() => calc = new Calculator();
[Test]
public void Add_TwoNumbers_ReturnsSum() {
int result = calc.Add(5, 3);
Assert.AreEqual(8, result);
}
}
This follows the Arrange–Act–Assert pattern, set up data, perform the action, and verify results.
Key NUnit Attributes
NUnit eases automation testing with C# as it is compatible with automation test suites such as Selenium, there are also many other uses of using Selenium check out What Is Selenium? Availability of annotations (or attributes) helps in speeding up the development of test cases. You can also use the NUnit framework for TDD (Test Driven Development). If you are preparing for an interview you can learn more through NUnit interview questions.

In this NUnit testing tutorial, NUnit setup example is demonstrated using Visual Studio 2019. Most of the .NET developers use Visual Studio for writing code as it eases the process of test case development, debugging, testing, and maintenance. NUnit Visual Studio Adapter is used to execute NUnit tests as it works with all the current editions of Visual Studio.
Before we look at the NUnit setup example, we need to setup the development environment (or IDE) for NUnit test case development. You need to follow the below steps for installing Visual Studio 2019 (VS 2019):



The next step is to install the NUnit framework along with setting up the NUnit Visual Studio Adapter.

Deliver immersive digital experiences with Next-Generation Mobile Apps and Cross Browser Testing Cloud
Take this certification to master the fundamentals of Selenium automation testing with C# and prove your credibility as a tester.
Here’s a short glimpse of the Selenium C# 101 certification from TestMu AI:
Automation testing with C# and NUnit framework can be performed by installing the NUnit framework and NUnit test adapter. There are two options for installing the NUnit adapter – using Visual Studio extension or using NuGet Package Manager. In this NUnit testing tutorial, we show you setup using both the options.
For installing the required NUnit packages, you can either use the IDE or use the NuGet Package Manager commands. If you are just getting started with NUnit, we would recommend that you use the IDE option.
To install the NUnit framework and NUnit Test Adapter, perform the following steps using the Visual Studio IDE:


Instead of using the IDE, you can use the Package Manager (PM) commands for installing the required NUnit packages.

Install-Package NUnit
Install-Package NUnit3TestAdapter
PM> Get-Package
Id Versions
-- --------
NUnit {3.12}
NUnit3TestAdapter {3.16.1}
The advantage of installing the NUnit Adapter using Visual Studio Extension (VSIX) is that extension will be automatically updated to the latest versions. Download the extension of NUnit Test Adapter from the Visual Studio gallery and double click on the same to install the extension.
A better option is to navigate to Tools -> Manage Extensions menu in Visual Studio. Click on Online and enter the search term as NUnit Test Adapter. Click on the search item labeled as NUnit 3 Test Adapter and install it.

With this NUnit setup example, we demonstrated how to setup the NUnit framework for Visual Studio. The steps listed in this NUnit testing tutorial can be used for getting started with Automation testing with C#.

This NUnit Tutorial for beginners and professionals will help you learn how to use NUnit framework with Selenium C# for performing Selenium automation testing.
With the NUnit framework setup, you can now create NUnit Test Project in Visual Studio. In this NUnit testing tutorial, we will also cover the steps to setup Selenium WebDriver with Visual Studio in C#. Prior to installing the Selenium WebDriver framework, we create a new project in Visual Studio:



As the NUnit project is ready, the next step is to setup the Selenium WebDriver for Visual Studio. For downloading the Selenium WebDriver on Visual Studio, we use NuGet, a free & open-source package manager specifically designed for the Microsoft platform.
You can install the Selenium WebDriver using the NuGet Package Manager (PM) Commands, i.e., Command Line option or Visual Studio IDE.
Perform the following steps to download Selenium WebDriver for Visual Studio using the GUI:




Instead of using the IDE, you can make use of the Package Manager (PM) commands for installing the required Selenium WebDriver package.

Install-Package Selenium.WebDriver
Install-Package Selenium.Chrome.WebDriver


PM> Get-Package
Id Versions
-- --------
Selenium.WebDriver {3.141.0}
Selenium.Chrome.WebDriver {79.0.0}
...... ......
...... ......
Give it a read: Top Selenium WebDriver Commands in NUnit
With this NUnit setup example, we demonstrated how to setup the NUnit framework & Selenium WebDriver with Visual Studio in C#. The steps listed in this NUnit testing tutorial can be used for getting started with automation testing with Selenium and C#. With the completion of NUnit & Selenium installation, you are all set to experience cross browser testing with Selenium C#.

Deliver immersive digital experiences with Next-Generation Mobile Apps and Cross Browser Testing Cloud
Did you find this page helpful?
More Related Hubs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance