Running and Interpreting Tests in Your Local Environment
Explore how to set up NUnit test projects and write test methods within your development environment. Understand how to run tests, interpret pass, fail, and skipped results, and use assertions to verify code correctness. This lesson guides you through managing test projects and analyzing outcomes using the Visual Studio test explorer to ensure code quality.
Introduction
NUnit is one of the most widely used unit testing frameworks in the .NET industry. NUnit code is essentially test code and the code that it tests is the application code. In your IDE, complete the following steps to set up an NUnit project:
- Create a .NET core 5.0 or 6.0 console application project called
Project. - In the same solution as the console application project, add an NUnit test project called
ProjectTest. - In the NUnit test project, add a reference to the console application project.
Set up an application code project and test code project
Set up an application code project and test code project in your IDE. The details on how to do this are included in the appendix of this course.
Initial application and test code
Add a class called Account in the Project. In the Account class, paste the following code:
The ProjectTest should have automatically created a file called ...