-
Notifications
You must be signed in to change notification settings - Fork 180
Command line
Robert Coltheart edited this page May 6, 2019
·
2 revisions
- Convert your
project.jsonto.csprojwith eitherdotnet migrateor Visual Studio IDE. - Replace the
dotnet-test-mspecNuGet package with theMachine.Specifications.Runner.VisualStudioone - Add the
Microsoft.NET.Test.Sdknuget package (required)
Done.
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>
Example output:
C:\code\mspec-test-sample\MSpecSampleSolution\Sample>dotnet test
Build started, please wait...
Build completed.
Test run for C:\code\mspec-test-sample\MSpecSampleSolution\Sample\bin\Debug\netcoreapp1.1\MSpecSample.dll(.NETCoreApp,Version=v1.1)
Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Machine Specifications Visual Studio Test Adapter - Executing Specifications.
Machine Specifications Visual Studio Test Adapter - Executing tests in C:\code\mspec-test-sample\MSpecSampleSolution\Sample\bin\Debug\netcoreapp1.1\MSpecSample.dll
Complete on 1 assemblies
Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 0.8338 Seconds
Test run for C:\code\mspec-test-sample\MSpecSampleSolution\Sample\bin\Debug\net46\MSpecSample.dll(.NETFramework,Version=v4.6)
Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Machine Specifications Visual Studio Test Adapter - Executing Specifications.
Machine Specifications Visual Studio Test Adapter - Executing tests in C:\code\mspec-test-sample\MSpecSampleSolution\Sample\bin\Debug\net46\MSpecSample.dll
Complete on 1 assemblies
Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 0.7364 Seconds
Getting Started
Test Runners
Guidelines