Legacy Documentation. View NUnit 3 Documentation

Release Notes

View Combined 2.5 Changes

NUnit 2.5 Final Release - Version 2.5.0.9122 - May 2, 2009

Framework

  • A new syntax element, Matches(Constraint), allows use of custom constraints, predicates or lambda expressions in constraint expressions.
  • The MessageMatch enum used with ExpectedExceptionAttribute has been extended with a new value StartsWith, indicating that the exception message must start with the string provided.
  • TestCaseAttribute now supports a MessageMatch property.

Gui

  • The File menu now allows selecting an alternate runtime, such as Mono, on a machine with multiple CLR implementations installed. This feature is still considered experimental and may change in the future.
  • The combo box in the Project Editor allowing selection of a particular runtime type such as Mono for loading the test has been re-enabled.

Bug Fixes

  • Provided a workaround to a Mono 2.4 bug in handling remote references to an interface, where the provider is running under MS .NET and the implementation is explicit.
  • Fixed a problem with the display of line numbers from a German language stack trace, with lines terminating in a period.
  • The Console Runner display now shows the settings for ProcessModel, DomainUsage and RuntimeFramework actually provided, before resolution of any defaults.
  • Removed references in the docs to pages that no longer exist.

NUnit 2.5 Release Candidate - Version 2.5.0.9117 - April 27, 2009

General

  • The installation now uses a 'lib' subdirectory to hold dlls.
  • The build script target names have been changed to make more sense. In particular, 'package' now builds the default package and targets not intended to be called directly are no longer listed as 'Main Targets' by the -projecthelp option.

Framework

  • The following Constraints now use the NUnit definition of equality in comparing items, which may lead to changed behavior of some tests.
    • UniqueItemsConstraint
    • CollectionContainsConstraint
    • CollectionEquivalentConstraint
    • CollectionSubsetConstraint
    The constraints listed now accept the IgnoreCase and Using modifiers, which work exactly as they do with EqualConstraint

Core

  • Caching is now used to reduce the time required to load tests.

Gui

  • A new submenu under File allows selecting a runtime version under which to reload the tests. Reloading in this way does not affect any runtime version setting in the project file.
  • The project editor now provides a combo box listing known versions of the runtime. Other versions may still be entered in the edit box. Cross-CLR execution (for example, running Mono from .NET) has been disabled in the Gui, since it isn't yet implemented.
  • The new stack trace display now follows the NUnit Font settings. The stack display uses the general gui font, while the source code display uses the fixed font.
  • The separate settings for Recent Files under .NET 1.1 and .NET 2.0 have been combined, since the Gui now runs exclusively under .NET 2.0.
  • The time required to restore the visual state of the tree after reloading has been substantially reduced, especially for large numbers of tests.

Bug Fixes

  • Use of a long assembly name for the ApplicationName of the AppDomain was causing excessively long paths in the shadow cache.
  • The Using modifier of EqualConstraint now works as expected for string operands.
  • TestCaseAttribute.ExpectedExceptionMessage is no longer ignored.
  • The max number of files setting was not being saved when modified in the Gui Settings dialog.
  • As a temporary fix, the pnunit.tests.dll has been moved to the same directory as pnunit-agent.exe and pnunit-launcher.exe, since pnunit tests don't allow for setting an appbase separate from the location of the test assembly.

NUnit 2.5 Beta 3 Release - Version 2.5.0.9096 - April 6, 2009

General

  • The Gui is now built against .NET 2.0 only. Tests may still be run under .NET 1.x by running in a separate process.
  • The Visual Studio 2003 solution has been removed. Framework and other components may still be built under .NET 1.x through the NAnt script.
  • The nunit.framework.extensions assembly has been removed from the build.

Framework

  • EqualConstraint has been enhanced with several new modifiers, which may be used immediately after the Within(...) modifier to indicate how a numeric tolerance value should be interpreted.
    • Ulps = as units in the last place (floating point only)
    • Percent = as a percentage of expected value
    • Days = as a TimeSpan in days
    • Hours = as a TimeSpan in hours
    • Minutes = as a TimeSpan in minutes
    • Seconds = as a TimeSpan in seconds
    • Milliseconds = as a TimeSpan in milliseconds
    • Ticks = as a TimeSpan in ticks
  • The comparison constraints (GreaterThan, LessThan, etc.), RangeConstraint and CollectionOrderedConstraint may now be used with objects that implement IComparable<T>.
  • The syntax used for specifying that a collection is ordered has changed. Is.Ordered is now a property. The property name to use for ordering is specified using Is.Ordered.By(name).
  • The following constraints now accept a Using modifier to indicate that a user-specified comparer should be used:
    • EqualConstraint
    • GreaterThanConstraint
    • GreaterThanOrEqualConstraint
    • LessThanConstraint
    • LessThanOrEqualConstraint
    • RangeConstraint
    • CollectionOrderedConstraint
    The provided comparer may be any of the following:
    • IComparer
    • IComparer<T>
    • Comparison<T>
    In addition, EqualConstraint may use:
    • IEqualityComparer
    • IEqualityComparer<T>

NUnit 2.5 Beta 2 Release - Version 2.5.0.9015 - January 15, 2009

Framework

  • NUnit now includes an implementation of Theories, similar to what is found in JUnit. Support for Theories is provided by the Theory, Datapoint and Datapoints attributes and by the Assume.That method. For more information and further links, see the TheoryAttribute documentation page.
  • AssertionHelper has been updated so that the Expect overloads now include the signatures newly introduced for Assert.That.
  • The code for Assert is now generated. This is in addition to the files that were generated in beta-1.
  • AfterConstraint has been renamed to DelayedConstraint.

Console

  • The console runner now supports a /framework option, which allows running the tests under a different version of the CLR.

Gui

  • The Gui is now able to display the source code for test or production code from the stack trace, provided the assemblies contain source code information and the source code is available. Contributed by Irénée Hottier.
  • Reloading the tests after changing settings in a way that modifies the shape of the tree is now handled correctly.
  • The Settings Dialog now opens to the page that was last viewed.

NUnit 2.5 Beta 1 Release - Version 2.5.0.8332 - November 27, 2008

General

  • Most of the code for elements of the constraint syntax is now generated. This allows us to more rapidly deploy new constraints with their corresponding syntax. The file SyntaxElements.txt contains the specifications used in generating the code. At this time, we are including both this file and the generated files with the NUnit source, so that those working in other areas of the code don't have to regenerate them each time they make changes.
  • The nunit.core.extensions assembly has been removed from the build. Features that were previously in that assembly are now in the nunit.core assembly.
  • All third-party addins have been removed from the build and must be downloaded separately from their own sites. An index of such addins is maintained on the NUnit site.

Framework

  • New attributes are provided to control use of threads by tests. All of the following may be used on methods, classes or assemblies:
    • RequiresThreadAttribute forces creation of a new thread and may optionally indicate the desired ApartmentState for the thread.
    • RequiresSTAAttribute causes the test to run in the STA. A new thread is created only if the parent is not in the STA. On methods, the .NET-provided STAThreadAttribute may also be used.
    • RequiresMTAAttribute causes the test to run in the MTA. A new thread is created only if the parent is not in the MTA. On methods, the .NET-provided MTAThreadAttribute may also be used.
    • TimeoutAttribute is used to set the timeout for tests. When used on classes or assemblies, the timeout value is used as the default timeout for all subordinate test cases. Test cases with a timeout value run on a separate thread and return a failure message if the timeout is exceeded.
  • The MaxTimeAttribute specifies a miximum elapsed time for a test case. If the test takes longer, it is reported as a failure. This attribute was previously available as an extension.

    Note: Unlike TimeoutAttribute, MaxTimeAttribute does not cause the test to be cancelled, but merely times it.
  • RepeatAttribute causes a test case to be executed multiple times. This attribute was previously available as an extension.
  • PairwiseAttribute now works, generating all pairs of each argument value. [In earlier betas, it was unimpemented and simply generated all combinations.]
  • PropertyAttribute has been modified internally to use a dictionary of name/value pairs rather than just a single name and value. This feature is not exposed for direct use, but may be accessed by derived attributes that want to apply multiple named values to the test. For a simple example of usage, see the code for RequiredThreadAttribute.
  • The presence of TestCaseSourceAttribute on a method is now sufficient to identify it as a test. As with TestCaseAttribute, use of TestAttribute is optional.
  • Assert.That has been extended to allow a delegate or a reference as the argument. By default, these are evaluated before being used by the constraint supplied but some constraints may delay evaluation. The new AfterConstraint is an example.
  • An additional overload of Assert.Throws allows passing a constraint or constraint expression as the first argument.
  • The syntax for AttributeConstraints has been enhanced so that further tests may be applied to properties of the attribute rather than just checking for its existence.
  • AfterConstraint allows delaying the application of a constraint until a certain time has passed. In it's simplest form, it replaces use of a Sleep in the code but it also supports polling, which may allow use of a longer maximum time while still keeping the tests as fast as possible. The After modifier is permitted on any constraint, but the delay applies to the entire expression up to the point where After appears.

    Note: Use of After with a simple value makes no sense, since the value will be extracted at the point of call. It's intended use is with delegates and references. If a delegate is used with polling, it may be called multiple times so only methods without side effects should be used in this way.

Core

  • NUnit now supports running tests in a separate process or in multiple processes per assembly. In addition, tests run in a separate process may use a different runtime version from that under which NUnit is running.

    Note: In the Beta release, execution of tests under Mono from a copy of NUnit that is running under .NET is not yet supported.

Console

  • The new /process:xxxxx command line option is used to run tests in a separate process or in multiple processes per assembly.
  • A new commandline option, /timeout:nnnn allows you to specify a default timeout value, which is applied to each test case in the run without a Timeout specified.

Gui

  • The Assembly Info display now uses a scrolling text box and has been enhanced to show information about the Process and AppDomain in which the test is running and the runtime version under that is being used.
  • The Project Editor now allows setting the ProcessModel and DomainUsage for a project to control how that project is loaded and run. It also supports setting a target runtime framework for each configuration. If the target runtime is different from the runtime under which NUnit is running, the tests will be run automatically in a separate process under the target runtime.
  • The Project Editor no longer reloads the tests as each individual change is made. Tests are reloaded after the editor is closed and only if changes have been made to the overall project configuration or to the active configuration.
  • The "Options" dialog is now called "Settings."

Extensibility

  • The implementation of constraints has been changed so that it is no longer necessary to create an additional "Modifier" class when a custom constraint takes modifiers. If you simply implement each modifier as a property or method returning the object itself, it will be usable in the full range of constraint expressions.

    Note: Although you can readily create custom constraints, this release of NUnit still lacks the ability to create new syntactic elements without rebuilding the framework.

Bug Fixes

  • Loading a single assembly and then adding another assembly using the Add Assembly menu item was not working correctly.
  • Reloading tests after settings changes was failing when the new settings changed the shape of the tree in such a way that the new tests didn't match the old ones correctly.
  • The Reload Project menu item was followed by a prompt asking if the current project state should be saved first and making the reload work in an unexpected way if you answered yes.
  • A class without a TestFixture attribute, containing only TestCase methods, without any Tests, was not recognized as a test fixture.
  • Assert.DoesNotThrow was failing to display a user message.
  • Xml documentation for Assert.IsNotEmpty and Assert.AreEqual was incorrect.
  • CollectionAssert.AreEqual and EqualConstraint were not working with IEnumerables that were not also Collections.
  • PlatformAttribute now distinguishes correctly between Vista and Windows 2008 Server.

NUnit 2.5 Alpha 4 Release - Version 2.5.0.8528 - September 14, 2008

Framework

  • Use of the TestFixtureAttribute is now optional in designating classes that contain tests.
  • More than one method may now be marked with the SetUp, TearDown, TestFixtureSetUp and TestFixtureTearDown attributes. Setups in a base class are executed before those in a derived class and teardowns are executed in the reverse order. If there are multiple setups or teardowns defined at the same level, the order is unspecified so this practice is not generally recommended.
  • The FactoryAttribute and TestCaseFactoryAttribute introduced in alhpa-3 have been removed. The new TestCaseSourceAttribute allows specification of the name of the source of test cases and - optionally - the type providing the source if it is not the same as the type that contains the test. Only one source may be specified per attribute but the attribute may be applied more than once to indicate multiple sources.
  • It is now possibe to specify Categories and Properties on test cases defined using the TestCaseData class.
  • Named fields, properties or methods may be used to provide values for individual method parameters using the new ValueSourceAttribute.
  • New constraints and corresponding syntactic constructs are provided:
    • Is.InRange tests that a value lies within a specified range.
    • Has.Attribute() tests for the presence of a specified attribute on a type.
    • Is.AssignableTo allows reversing the operands of AssignableFrom for increased clarity in the code and in any error messages when the actual value is of the derived type.
    • Throws.Exception allows testing the exception thrown by a delegate in place and provides the ability to make arbitrary tests on the caught exception. Throws.TypeOf() and Throws.InstanceOf() are provided as shorthand for the commonly used Throws.Exception.TypeOf() and Throws.Exception.InstanceOf.
    • Throws.Nothing provides for testing that a delegate does not throw. While it doesn't do much, it serves the purpose of converting an unexpected error into a test failure.
  • The parsing of constraint expressions written using the fluent interface has been reorganized internally, with the following benefits:
    • Meaningless sequences like "...Null.Null..." or "...And.Or..." will no longer compile - the NUnit tests actually verify this by attempting to compile them.
    • Syntax modifiers like Within and IgnoreCase are now only accepted - and shown by intellisense - on constraints that actually make use of them.
    • New And and Or infix operators are provided.
    • The With provides some ability to group constraints.

    Note: Operators are evaluated in the following order:

    1. Postfix modifiers (highest)
    2. Not Operator
    3. And operator (see below)
    4. Or operator (see below)
    5. With operator
    6. Some, None and All operators
    7. And operator when followed directly by Some, None or All
    8. Or operator when followed directly by Some, None or All
    9. Overloaded operator &
    10. Overloaded operator | (lowest)
    Operators of equal precedence associate left to right.
  • The "syntax helper" classes, Is, Has, Text and List have been moved to the NUnit.Framework namespace, since they seem to have entered the mainstream.
  • NUnit 2.5 is able to recognize, load and run NUnitLite tests.
  • PropertyConstraint now works with Types when testing for the existence of a named property.

Core

  • Experimental support is provided for running tests in a separate process. Currently, this is only exposed in the Gui runner.
  • NUnit recognizes a special attribute on the config element of the nunit project file, runtimeFramework, which may be set to "net-1.1" or "net-2.0." This causes use of the appropriate runner if tests are run in a separate process.

    Note: Both of the above features are experimental and somewhat fragile. Results are expected to vary for different installations and we ask that problems be reported.

Gui

  • The Addin Dialog now shows an error message for any addin that fails to load. (from 2.4.8)
  • The TestLoader settings dialog provides an option for running tests in a separate process.
  • The Assembly Info display now shows two runtime versions for each test assembly: the one for which it was built and the one under which it is currently loaded.

Extensibility

  • The RequiredAddinAttribute is now only permitted at the assembly level.

Bug Fixes

  • The Gui output panes were failing to use a fixed font. (from 2.4.8)

NUnit 2.5 Alpha 3 Release - Version 2.5.0.8189 - July 7, 2008

General

  • NUnit now uses a new version numbering scheme. The first three dot-separated values represent the release level, as before, while the fourth is a build number tied to the date of the release. This alpha release, for example, is numbered 2.5.0.8189.
  • The NUnit source now includes a VS2008 project, in addition to the existing VS2005 and VS2003 projects

Framework

  • DataSourceAttribute has been replaced with FactoryAttribute. The new attribute may refer to any field, method or property that provides test cases consistent with the signature of the method on which it appears. The naming of this attribute is still a bit unsatisfactory and it may change in the final release.
  • The new TestCaseFactoryAttribute class may be used to mark a field, method or property that provides test cases. It specifies the argument types of the test cases that will be provided and is used to identify the cases to be used when the name of a factory is not specified.
  • Data may be specified for individual arguments of a parameterized test using the new attributes: ValuesAttribute, RangeAttribute and RandomAttribute. By default, test cases are created using every possible combination of the items provided. Attributes on the test method may specify how data is combined. This release includes SequentialAttribute, CombinatorialAttribute (the default) and PairwiseAttribute. However, Pairwise combination is not yet implemented, so that attribute is currently ignored.
  • TestFixture classes may now be generic. They must be marked with or or more instances of TextFixtureAttribute using the new constructor that takes an array of Types. NUnit will instantiate the fixture multiple times, using the type arguments provided.
  • Parameterized test methods may now be generic. NUnit will deduce the correct implementation to use based on the types of the parameters provided.
  • The new RequiredAddinAttribute may be used to mark tests, fixtures or assemblies, indicating the name of any addin that is required to run the tests. If the addin is not present, the test, fixture or assembly is marked NotRunnable.
  • A new assertion and corresponding constraint IsOrdered has been added. (contributed by Simone Busoli)
  • PlatformAttribute has been extended to accept the new keywords NT6, Vista and Win2008Server.

    Note: In the current alpha release, NUnit is unable to distintuish between Vista and Windows 2008 Server. Either of them will match all the above values.

Gui

  • Properties with a collection for a value are now displayed displayed as a comma-separated list in the properties window.

Extensibility

  • The IParameterProvider interface has been replaced with ITestCaseProvider. The ParameterProviders extension point has been renamed to TestCaseProviders.
  • A new extension point, DataPointProviders, has been added to support extensions that provide data for individual test parameters. Extensions must implement the IDataPointProvider interface.
  • A simpler method of providing new data point extensions based on attributes applied to the parameter itself is also available. Such attributes may be derived from ValuesAttribute and do not require any special addin in order to work.

Bug Fixes

  • NUnit tests of AssertThrows were not working on systems using non-English cultures.
  • Domains were not unloading correctly in some circumstances. Unloading is now done on a separate thread.
  • An NUnitSettings.xml file of zero length was causing a crash. (from 2.4.8)
  • Invoking the gui with /exclude:XXX, where XXX is a non-existent category, was causing all tests to be excluded. (from 2.4.8)
  • Categories were not working properly on repeated tests. (from 2.4.8)
  • A serious memory leak was fixed in the NUnit test runners. (from 2.4.8)
  • Static SetUp and TearDown methods were not being called in a SetUpFixture.
  • The current directory used when executing addins that load tests was not correctly set.

NUnit 2.5 Alpha 2 Release - May 7, 2008

Note: Since this is an alpha level release, the features are not complete and some features present in this release may be removed or changed in future releases.

General

  • This release includes pNUnit, an extended NUnit runner for distributed parallel tests. The pNUnit program was developed at Codice Software for use in testing the Plastic SCM and has been contributed to NUnit. For more info about using pNUnit see the pNUnit site.
  • The install now offers Typical, Complete and Custom options. Selecting Typical gets you the NUnit framework, core, console runner and Gui. To install pNUnit, any of the bundled addins or the NUnit tests, select Complete or Custom.

Extensibility

  • The RowTestExtension, which was merged into the nunit extension dlls in Alpha-1, is now provided as a separate addin. This is the general approach we plan to take with regard to any bundled addins, since it permits the creator of an addin to provide updates separately from the NUnit release.
  • This release includes the CSUnitAddin extension, which allows the running of CSUnit tests under NUnit. The csunit.dll must be available in order to run the tests.

NUnit 2.5 Alpha 1 Release - April 18, 2008

General

  • There are no longer separate distributed packages for .NET 1.1 an 2.0. Both the binary zip and msi packages contain subdirectories for .NET 1.1 and 2.0. In the case of the msi, the user may elect to install either or both of them.
  • The Visual Studio solutions and projects are now in a directory tree that is parallel to the source tree. This eliminates problems where the VS2003 and VS2005 builds were interfering with one another and makes room for adding VS2008.
  • NUnit is now built using NAnt 0.86 beta 1
  • The windows installer is now created using WiX 2.0.5085

Framework

  • Two new attributes have been added to support passing arguments to test methods:
    • TestCaseAttribute allows the programmer to specify the arguments and a number of optional parameters inline.
    • DataSourceAttribute identifies a static property that will provide the arguments and other parameters.
  • Two new constraints have been added to permit testing of application-created paths, without requiring that they exist in the file system. The following syntax is supported:
    • Is.SamePath(string)
    • Is.SamePathOrUnder(string)
  • The DirectoryAssert class has been added, providing the following Methods:
    • AreEqual(DirectoryInfo, DirectoryInfo)
    • AreEqual(string, string)
    • AreNotEqual(DirectoryInfo, DirectoryInfo)
    • AreNotEqual(string, string)
    • IsEmpty(DirectoryInfo, DirectoryInfo)
    • IsEmpty(string, string)
    • IsNotEmpty(DirectoryInfo, DirectoryInfo)
    • IsNotEmpty(string, string)
    • IsWithin(DirectoryInfo, DirectoryInfo)
    • IsWithin(string, string)
    • IsNotWithin(DirectoryInfo, DirectoryInfo)
    • IsNotWithin(string, string)
  • The method Assert.Throws(Type expectedException, TestSnippet code) has been added to provide more control over tests of expected exceptions. TestSnippet is a delegate, which may of course be supplied anonymously under .NET 2.0. If the correct exception type is thrown, the actual exception is returned from the method, allowing further verification to be performed.
  • The Assert.DoesNotThrow method may be used to verify that a delegate does not throw an exception.
  • The Assert.Pass method allows early termination of a test with a successful result.
  • The Assert.Inconclusive method allows returning the new Inconclusive result state.
  • NUnit now includes added funtionality in the .NET 2.0 build of the framework. The following additional features are supported:
    • All Asserts and Constraints work with nullable types.
    • Some Asserts allow an alternate generic syntax for convenience:
      • Assert.IsInstanceOf<T>(object actual);
      • Assert.IsNotInstanceOf<T>(object actual);
      • Assert.IsAssignableFrom<T>(object actual);
      • Assert.IsNotAssignableFrom<T>(object actual);
      • Assert.Throws<T>(TypeSnippet code);
  • The following obsolete interfaces, classes and methods have been removed:
    • The IAsserter interface
    • The AbstractAsserter class
    • The Assertion class
    • The AssertionFailureMessage class
    • The old NUnit.Framework.TestCase class used for inheriting test classes
    • The Assert.DoAssert() method
    • Two ExpectedExceptionAttribute(Type, string) constructor
    • Two ExpectedExceptionAttribute(string, string) constructor
  • The syntactic constructs in the SyntaxHelpers namespace have been moved to the NUnit.Framework.Syntax.CSharp namespace. The old namespace may still be used for existing classes, but will not be supported after the 2.5 release.

Core

  • NUnit now allows use of static methods as tests and for SetUp, TearDown, TestFixtureSetUp and TestFixtureTearDown.
  • Failures and Errors are now distinquished internally and in summary reports. Methods that are not run because they are invalid are also reported separately.

Console

  • The summary report now displays Errors, Failures, Inconclusive, Ignored and Skipped tests separately. More detailed information on non-runnable tests and setup failures is provided.
  • The console summary report is no longer created using a stylesheet, which renders the /transform option meaningless. The option has been removed.

Gui

  • The default gui display now uses a single tab for all text output. For users upgrading from an earlier release, the current settings are honored. If you wish to change to the new default, use the Restore Defaults button on the Text Output settings dialog.
  • The final test run display shows a more detailed summary: passed tests, errors, failures, inconclusive, non-runnable, skipped and ignored.
  • The status bar now displays errors and failures separately in.
  • The tree display shows non-runnable tests in red and inconclusive tests in orange. Inconclusive tests are temporarily listed on the Tests Not Run tab for this alpha release.

Extensibility

  • A new extension point ParameterProviders allows addins to provide data for parameterized tests.
  • The following extensions are included in the nunit.core.extensions and nunit.framework.extensions assemblies:
    • The MaxTime extension, which was previously a sample.
    • The RowTest extension, which remains an alternative to NUnit's native TestCase syntax.
    • The XmlConstraint extension, which allows comparing two xml files