Table of Contents

Core Framework v2 2.3.0 2017 October 6

Today, we're shipping two new releases:

  • xUnit.net Core Framework v2 2.3.0
  • xUnit.net Visual Studio adapter 2.3.0

It's been nearly 8 months since the release of 2.2.0. That was strongly aligned with .NET Core 1.0, and in the intervening time, that team has now shipped a substantial 2.0 update. Similarly, xUnit.net 2.3 feels like it has a much improved experience for .NET Core users (both 1.x and 2.x).

One of the core reasons we've done xUnit.net has been to improve the day-to-day unit testing experience for .NET developers. At a previous job, we had discussions about adding Roslyn code analyzers to xUnit.net as a way to make our guidance more concrete. These rules and fixes would represent our knowledge with issues commonly faced by unit testers in general, and xUnit.net users in particular. Marcin Dobosz, one of our co-workers at the time, has stepped up and has done a tremendous job with the xUnit.net Analyzers project. Although this hasn't yet reached 1.0 status, we've already started including them when you reference the xunit meta-package; as a result, you will see our guidance light up as warnings and errors in your code.

Visual Studio 2017 has seen some substantial improvements since its release 7 months ago, with some great things on the horizon with 15.4 and 15.5. We are currently working on updated templates for the next release of the .NET SDK and a future update to Visual Studio 2017 which will include 2.3 references.

As always, we'd like to thank all the users who contributed to the success of xUnit.net through usage, feedback, and code. 🎉

Important

If you are using Visual Studio 2013, you must use NuGet 2.12 or later to use xUnit.net 2.3, because support for netstandard is required. You will not be able to use xUnit.net 2.3 with Visual Studio 2012 (if Visual Studio 2012 support is important, please stick with xUnit.net 2.1, the last version that officially supported 2012).

Note

As a reminder: If you're extending xUnit.net and want to publish your extension as a NuGet package, you should import xunit.extensibility.core and/or xunit.extensibility.execution, not xunit or xunit.core. If you do this wrong, you might have problems generating your NuGet package via dotnet pack.

Release Notes

These release notes are a comprehensive list of changes from 2.2.0 to 2.3.0.

General

  • As mentioned above, the xunit meta-package now includes a reference to the xunit.analyzers package automatically. We feel most users will benefit from these helpful rules and fixes. If you decide you would like to opt out, please remove your reference to xunit, and instead add references to xunit.core and xunit.assert.

  • A significant amount of work was put into general performance improvements. The largest performance gains will be experienced by users who are running tests in the desktop CLR with app domains enabled (the default behavior). Additionally, we have spent time optimizing performance in the Visual Studio Test Explorer experience.

  • This is the first version to fully support .NET Core 2.0, and the support for .NET Core 1.0 has been greatly improved. In particular, users who noticed that we were copying large numbers of dependent DLLs will be happy to note that we have found a way around that. Also, any users who were previously trying to use libraries with native components (for example, System.Data.SqlClient) from .NET Core should now be able to properly use these packages (this fix affects all versions of .NET Core).

Core Framework

  • We added the ability to disable cross-collection parallelization for individual test collections, via the test collection definition (by setting [CollectionDefinition(DisableParallelization = true)]). Parallel-capable test collections will be run first (in parallel), followed by parallel-disabled test collections (run sequentially).

  • Updated TheoryData to support up to 10 data parameters.

  • BUG: Fixed an issue where grandparent and higher classes were not being correctly traversed to find test method info.

  • BUG: Fixed an issue when running .NET Core 1.x tests would fail if the .NET 2.0 SDK was being used.

  • BUG: [.NET Core] Fixed an issue where incorrect platform DLLs could be loaded (for example, loading the unix reference library on Windows).

  • BUG: [.NET Core] Fixed an issue where native libraries might not get loaded.

Assertion Library

  • Assert.Empty will now include the collection in the error message when the assert fails.

  • Added support for IComparable<> in Assert.Equal.

  • Improved compatibility with IEquatable<> and Assert.Equal.

Console Runner

  • BREAKING CHANGE: The xunit.runner.console NuGet package has been changed; notably, the path to the net452 executables has moved from tools\ to tools\net452\. You will need to update any paths which previously hard-coded this path.

  • When importing the xunit.runner.console NuGet package, you now have access to two properties which point to the on-disk location of the console runner executable: XunitConsolePath points to xunit.console.exe, and XunitConsolePathX86 points to xunit.console.x86.exe.

  • The console runner will now ensure the directory for results files (XML, HTML, etc.) exists.

  • Added a new -stoponfail switch to stop running tests after the first test failure.

  • BUG: Fixed an issue where the xunit.runner.console NuGet package caused MSBuild errors after being installed.

  • BUG: Fixed an issue where bright colors would not show up on Linux or OS X consoles that reported only 8-color support. This would cause some text to become illegible.

MSBuild Runner

  • BREAKING CHANGE: The xunit.runner.msbuild NuGet package has been changed; notably, the names of the MSBuild runner DLLs now include the target platform. This means if you had a hard-coded path to xunit.runner.msbuild.dll, this will need to be replaced with xunit.runner.msbuild.net452.dll.

  • Added an XunitTest target when imported xunit.runner.msbuild which will run the the current assembly. This allows you to run msbuild /t:XunitTest against your unit test projects without modifying the project file. Note: you can override several options by defining <PropertyGroup> items. For a complete list of supported property names, see: xunit.runner.msbuild.targets.

  • Added a new StopOnFail attribute to stop running tests after the first test failure.

Extensibility

  • Added a netcoreapp1.0 version of xunit.runner.utility and xunit.runner.reporters.

  • Started the process of separating user diagnostic messages from internal diagnostic messages. Runners have new options (as do configuration files) for enabling one vs. the other. This should make debugging extensibility projects simpler. This work is ongoing, so if you see internal diagnostic messages showing up without the switch, please feel free to file an issue.

  • XunitTestCaseRunner has several new override methods that make it easier to extend specific parts of the pipeline (creating tests, the test runner, and supplementing the before/after attributes for a test).

  • XunitTestFrameworkDiscoverer has exposed the mapping between Fact-derived attributes and the discoverer that is used to find them, allowing the user easier access to the cache (as well as allowing them to pre-seed the cache).

  • Added sbyte and Nullable<sbyte> as serializable types.

  • MemberDataAttributeBase can support data that is expressed as the non-generic IEnumerable, in addition to the generic IEnumerable<T>.