Sunday, October 13, 2019

NUnit Framework


                                        Image result for NUnit

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


  1. NUnit runs very well with .NET programming languages.
  2. It is open source and it is free.
  3. It is easy to integrate it with testing projects.
  4. NUnit works with many integrated runners including Resharper and TestDriven .NET.
  5. NUnit has frequent version updates.
  6. NUnit has a graphical user interface.
  7. 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.

AnnotationUsage
Category             Specifies one or more categories for the test
CultureSpecifies cultures for which a test or fixture should be run
IndicatesIndicates that a test should be skipped unless explicitly run
IgnoreIndicates that a test shouldn't be run for some reason
MaxTimeSpecifies the maximum time in milliseconds for a test case to succeed
OneTimeSetUpIdentifies methods to be called once prior to any child tests
OneTimeTearDownIdentifies methods to be called once after all child tests
PlatformSpecifies platforms for which a test or fixture should be run
RandomSpecifies generation of random values as arguments to a parameterized test
RepeatSpecifies that the decorated method should be executed multiple times
RetryCauses a test to rerun if it fails, up to a maximum number of times
TearDownIndicates a method of a TestFixture called immediately after each test method
TestMarks a method of a TestFixture that represents a test
TestCaseMarks a method with parameters as a test and provides inline arguments
TimeoutProvides a timeout value in milliseconds for test cases
SetUpIndicates 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

WebService, API and their Difference

Web service (WS) A service offered by an electronic device to another electronic device, communicating with each other via the World W...