What Is NUnit
NUnit is a unit-testing framework for all.Net languages. Initially ported from JUnit, the current production release, version 2.2, is the fourth major release of this xUnit based unit testing tool for Microsoft .NET. It is written entirely in C# and has been completely redesigned to take advantage of many .NET language features, for example, custom attributes and other reflection related capabilities. NUnit brings xUnit to all .NET languages.
Definition
• NUnit is an automated unit-testing framework for all.Net languages.
• Initially ported from JUnit, which is a unit testing framework for Java applications.
• It is written entirely in C# and has been completely redesigned to take advantage of many .NET language features.
• NUnit brings xUnit to all test are written in .NET supported language e.g. C#, VC, VB.NET, J#, etc.
• NUnit is an open source free to use with your .NET projects.
• NUnit provides a class library which includes some classes, features, and methods to help you write test scripts.
• NUnit provides user interface application to execute the test scripts and displays result
• NUnit does not create any test scripts by itself. We have to write test scripts and use NUnit tools and classes to make the unit testing easier and display the result as a success or failure.
Features of NUnit
(1) Assertions
(2) Attributes
Assertions:-
Assertions are central to unit testing in any of the xUnit frameworks, and NUnit is no exception. NUnit provides a rich set of assertions as static methods of the Assert class.
The most commonly used assertions.
• Equality Asserts
• Identity Asserts
• Comparison Asserts
• Type Asserts
• Condition tests
• Utility methods
• StringAssert
• CollectionAssert
• FileAssert
• Equal Constraint (Available NUnit 2.4)
• Same As Constraint (Available NUnit 2.4)
• Condition Constraints (Available NUnit 2.4)
• Comparison Constraints (Available NUnit 2.4)
• Type Constraints (Available NUnit 2.4)
• String Constraints (Available NUnit 2.4)
• Collection Constraints (Available NUnit 2.4)
• Compound Constraints (Available NUnit 2.4)
• Custom Constraints (Available NUnit 2.4)
Attributes
• Category
• Description
• ExpectedException
• Explicit
• Ignore
• Platform
• Property
• SetUp
• SetUpFixture
• Suite
• TearDown
• Test
• TestFixture
• TestFixtureSetUp
• TestFixtureTearDown