Skip to content

Command line

Robert Coltheart edited this page May 7, 2019 · 2 revisions

dotnet test

The runner lives in the Machine.Specifications.Runner.VisualStudio NuGet package, but note that a reference to the Microsoft.NET.Test.Sdk NuGet package is also required.

Once those two are installed either dotnet test can be used or Visual Studio's Test Explorer.

Multi-targeting is supported for .NET Core and .NET framework 4.6+

Here is an example .csproj targeting both .NET Core 1.1 and .NET Framework 4.6:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>    
    <TargetFrameworks>netcoreapp1.1;net46</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Machine.Specifications" Version="0.11.0" />
    <PackageReference Include="Machine.Specifications.Runner.VisualStudio" Version="2.*" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.*" />
  </ItemGroup>
</Project>

Console runner

MSpec tests can be run using the standalone console runner by installing the Machine.Specifications.Runner.Console package from Nuget.

The console runner comes in different flavors:

  • mspec.exe, AnyCPU, runs on the CLR 2.0
  • mspec-x86.exe, x86, runs on the CLR 2.0
  • mspec-clr4.exe, AnyCPU, runs on the CLR 4.0
  • mspec-x86-clr4.exe, x86, runs on the CLR 4.0

Help can be obtained by running mspec.exe --help, and the console runner can be used as follows:

Usage: mspec.exe [options] <assemblies>
Options:
-f, --filters               Filter file specifying contexts to execute (full type name, one per line). Takes precedence over tags
-i, --include               Executes all specifications in contexts with these comma delimited tags. Ex. -i "foo,bar,foo_bar"
-x, --exclude               Exclude specifications in contexts with these comma delimited tags. Ex. -x "foo,bar,foo_bar"
-t, --timeinfo              Shows time-related information in HTML output
-s, --silent                Suppress progress output (print fatal errors, failures and summary)
-p, --progress              Print dotted progress output
-c, --no-color              Suppress colored console output
-w, --wait                  Wait 15 seconds for debugger to be attached
--teamcity                  Reporting for TeamCity CI integration (also auto-detected)
--no-teamcity-autodetect    Disables TeamCity autodetection
--appveyor                  Reporting for AppVeyor CI integration (also auto-detected)
--no-appveyor-autodetect    Disables AppVeyor autodetection
--html <PATH>               Outputs the HTML report to path, one-per-assembly w/ index.html (if directory, otherwise all are in one file)
--xml <PATH>                Outputs the XML report to the file referenced by the path
-h, --help                  Shows this help message
Clone this wiki locally