NUnit 3 Compatibility Report
The /compatibility option of the console runner causes a compatibility report to be produced, which identifies potential compatibility issues when converting to NUnit 3. The report identifies issues in the command-line and in the test code itself.
Corrective actions to take to resolve each issue are prefixed by the minimum version of NUnit in which the action is possible. For example, actions marked 3.0: can only be taken after upgrading to NUnit 3, while those marked 2.6.5: are available under NUnit 2.6.5. Actions marked 2.x> are available in any version of NUnit V2.
Starting with release 2.6.7 of the console runner, it is possible to use the compatibility option with tests that reference older versions of NUnit V2. Some problems, however, will not be detected in this situation. For each type of issue, below, we indicate whether a specific framework version is needed in order to detect it.
Command-line Issues
These issues are detected for all 2.x framework versions.Option | Level | NUnit 3 Issue | Action |
---|---|---|---|
/process | Warning | Defaults to Multiple | 3.0: Allow to default or select option. |
/domain | Warning | Defaults to Multiple | 3.0: Allow to default or select option. |
/fixture | Error | Not available | 2.6.5: Use --test option. 3.0: Use --where option. |
/run | Error | Not available | 2.6.5: Use --test option. 3.0: Use --where option. |
/runlist | Error | Not available | 2.6.5: Use --testlist. |
/include | Error | Not available | 3.0: Use --where. |
/exclude | Error | Not available | 3.0: Use --where. |
/apartment | Error | Not available | 2.6.5: Use the ApartmentAttribute instead. |
/xml | Error | Not available | 2.6.5: Use --result. |
/noxml | Error | Not available | 2.6.5: Use --noresult. |
/xmlConsole | Error | Not available | 2.X: Remove. |
/basepath | Error | Not available | 2.X: Remove. |
/privatebinpath | Error | Not available | 2.X: Remove. |
/cleanup | Warning | Not available | 2.X: Remove - not needed. |
/nodots | Warning | Not available | 2.X: Remove - not needed. |
Issues in the Test Code
Attributes
These issues are detected for all 2.x framework versions.Name | Level | NUnit 3 Issue | Action |
---|---|---|---|
ExpectedExceptionAttribute | Error | Not available. | 2.X: Use Assert.Throws or Assert.That(..., Throws...). |
IgnoreAttribute | Error | Must have a reason specified. | 2.X: Specify a reason. |
NUnitAddinAttribute | Error | Not available. Addins are no longer suppported. | 3.0: Use custom attributes or engine extensions. |
RequiredAddinAttribute | Error | ||
RequiresMTAAttribute | Error | Not available. | 2.6.5: Use ApartmentAttribute. |
RequiresSTAAttribute | Error | ||
SetUpAttribute | Error | No longer allowed in a SetUpFixture. | 2.6.5: Use OneTimeSetUpAttribute. |
SuiteAttribute | Error | Not available. | 2.X: Restructure tests to eliminate legacy Suites. |
TearDownAttribute | Error | No longer allowed in a SetUpFixture | 2.6.5: Use OneTimeTearDownAttribute. |
TestCaseAttribute | Error | No longer supports ExpectedException. | 2.X: Use Assert.Throws or Assert.That(..., Throws...). |
TestCaseAttribute | Error | No longer supports Result property. | 2.6.5: Use ExpectedResult. |
TestCaseAttribute | Error | Ignore property changes from bool to string. | 3.0: Specify reason as value. |
TestCaseSourceAttribute | Error | Must reference a static member. | 2.6.5: Use a static field, property or method. |
TestCaseSourceAttribute | Error | No longer supports ExpectedException. | 2.X: Use Assert.Throws or Assert.That(..., Throws...). |
TestCaseSourceAttribute | Error | Ignored case requires a reason. | 2.X: Specify a reason. |
TestFixtureAttribute | Error | Ignore property changes from bool to string. | 3.0: Specify reason as value. |
TestFixtureSetUpAttribute | Error | Not available. | 2.6.5: Use OneTimeSetUpAttribute. |
TestFixtureTearDownAttribute | Error | Not available. | 2.6.5: Use OneTimeTearDownAttribute. |
ValueSourceAttribute | Error | Must reference a static member. | 2.X: Use a static field, property or method. |
System.MTAThread | Warning | Has no effect. | 2.6.5: Use ApartmentAttribute. |
System.STAThread | Warning | Has no effect. | 2.6.5: Use ApartmentAttribute. |
Assertions and Constraints
These issues are only detected for versions 2.6.5 and later of the framework.Feature | Level | NUnit 3 Issue | Action |
---|---|---|---|
Assert.IsNullOrEmpty | Error | Not available. | 2.X: Use Assert.That(..., Is.Null.Or.Empty). |
Assert.IsNotNullOrEmpty | Error | Not available. | 2.X: Use Assert.That(..., Is.Not.Null.Or.Empty). |
AssertionNelper | Error | Not available. | 2.X: Use standard constraint syntax or consider third-party NUnit.StaticExpect package. |
Is.InstanceOfType | Error | Not available. | 2.X: Use Is.InstanceOf. |
Is.StringContaining | Error | Not available. | 2.6.5: Use Does.Contain. |
Is.StringStarting | Error | Not available. | 2.6.5: Use Does.StartWith. |
Is.StringEnding | Error | Not available. | 2.6.5: Use Does.EndWith. |
Is.StringMatching | Error | Not available. | 2.6.5: Use Does.Match. |
NullOrEmptyStringConstraint | Error | Not available. | 2.X: Use separate constraints or see Assert.IsNullOrEmpty above |
Text.All | Error | Not available. | 2.X: Use Is.All or Has.All. |
Text.Contains | Error | Not available. | 2.6.5: Use Does.Contain. |
Text.DoesNotContain | Error | Not available. | 2.6.5: >Use Does.Not.Contain. |
Text.StartsWith | Error | Not available. | 2.6.5: Use Does.StartWith. |
Text.DoesNotStartWith | Error | Not available. | 2.6.5: Use Does.Not.StartWith. |
Text.EndsWith | Error | Not available. | 2.6.5: Use Does.EndWith. |
Text.DoesNotEndWith | Error | Not available. | 2.6.5: Use Does.Not.EndWith. |
Text.Matches | Error | Not available. | 2.6.5: Use Does.Match. |
Text.DoesNotMatch | Error | Not available. | 2.6.5: Use Does.Not.Match. |
Other Issues
These issues are detected for all 2.x versions that support async.Feature | Level | NUnit 3 Issue | Action |
---|---|---|---|
Async tests returning void | Error | Not available. | 2.x: Return Task. |