NUnit is a unit-testing framework for all .Net languages. Initially ported from JUnit, the current production release, version 3, has been completely rewritten with many new features and support for a wide range of .NET platforms.
NUnit is a test Framework like JUnit, where you can define your tests cases, tests suites and assertions. NUnit can run all the tests and show you a report. NUnit, like JUnit, enables test-driven development. NUnit tests can also run in Taurus.
The use of NUnit framework
- NUnit runs very well with .NET programming languages.
- It is open source and it is free.
- It is easy to integrate it with testing projects.
- NUnit works with many integrated runners including Resharper and TestDriven .NET.
- NUnit has frequent version updates.
- NUnit has a graphical user interface.
- Very easy integration with Visual Studio and other IDEs.
NUnit is basically composed of attributes, or annotations. These indicate to the framework to execute the tests that are implemented in the class, and also how to interpret them. Annotations tell the framework how to interpret the code. After this code is compiled, a dll file is generated that can be executed through a console or using the graphic interface. Tests also include assertions that allow checking and comparing values.
Important NUnit Annotations
The NUnit annotations are very easy to use: just add the annotation between brackets before the method declaration. With the annotation you can define the test: behavior (specifying Setup or TearDown method), assertions for example performance assertions like MaxTime method, and information like the Category method.
Annotation | Usage |
Category | Specifies one or more categories for the test |
Culture | Specifies cultures for which a test or fixture should be run |
Indicates | Indicates that a test should be skipped unless explicitly run |
Ignore | Indicates that a test shouldn't be run for some reason |
MaxTime | Specifies the maximum time in milliseconds for a test case to succeed |
OneTimeSetUp | Identifies methods to be called once prior to any child tests |
OneTimeTearDown | Identifies methods to be called once after all child tests |
Platform | Specifies platforms for which a test or fixture should be run |
Random | Specifies generation of random values as arguments to a parameterized test |
Repeat | Specifies that the decorated method should be executed multiple times |
Retry | Causes a test to rerun if it fails, up to a maximum number of times |
TearDown | Indicates a method of a TestFixture called immediately after each test method |
Test | Marks a method of a TestFixture that represents a test |
TestCase | Marks a method with parameters as a test and provides inline arguments |
Timeout | Provides a timeout value in milliseconds for test cases |
SetUp | Indicates a method of a TestFixture called immediately before each test method |
NUnit Test Results
NUnit provides a console mode, the nunit-console, which facilitates its use in the continuous integration process. In the console, the pass-fail results are provided immediately and no subjective human judgments or interpretations of test results are required.
NUnit also has a graphical user interface, similar to the one used in JUnit, which it makes it easy to use for JUnit users. In the GUI you can see the execution of the tests, the test that is running and how many tests succeeded and failed.
Ref: NUnit.org
blazemeter.com
No comments:
Post a Comment