NUnit : Introduction


There are several unit test tools in the market, but one of them is NUnit, the most popular tool for doing unit testing. So in this tutorial, we will learn the Unit Testing using the NUnit tool and will try to determine the reason for its popularity.

 

Unit Testing

 

The smallest unit of code is Function in an application: an application/software contains multiple Modules, and each Module composed various Classes and each class wrapped numerous Functions.

 

When we test individual function behavior without touching any other functions and determine whether it works exactly as per the requirements or not that is called Unit Testing.

 

Advantage of Unit Testing

 

1- Defects found early in development life cycle.

2- Reliable code.

3- Maintainable Code.

4- Faster testing by only single click of action.

 

NUnit

 

NUnit is the most used framework for writing unit test cases in the .NET. It supports both C# and VB.NET for coding, and it always suggests to write code in different assemblies that called Test Assemblies. These assemblies contain only testing code, nothing else. To check the test cases are failed or passed, run these test assemblies. For that, we required the Test Runner.

 

Test Runners is a UI tool that runs the NUnit test case and shows the test case results whether they have passed or failed. We will learn about test runners in the environment set-up in the next post.

 

NUnit can be used easily. There are some custom Attributes, and some Assert Classes are available in the NUnit tool that makes it easy to write unit tests.

 

Custom attributes provide a hint to NUnit test runners that these classes or functions contain unit testing code. Assert Classes use to test the conditions whether the system under test (SUT) satisfies a condition or not. If the condition met, then the test is pass else fail.

 

Some of the custom attributes are listed below: 

  • TestFixture
  • Setup
  • TearDown
  • Test
  • Category
  • Ignore
  • TestCase
  • Repeat
  • MaxTime


No comments:

Post a Comment

Please do not enter any spam link in the comment box.

Related Posts

What is the Use of isNaN Function in JavaScript? A Comprehensive Explanation for Effective Input Validation

In the world of JavaScript, input validation is a critical aspect of ensuring that user-provided data is processed correctly. One indispensa...