1

I have a test project configured with .NET Standard 1.5

IDE: Visual Studio 2017 Community

I have included xunit and xunit.runner.console but I cannot run the tests. I tried dotnet test on the test project but I get the following error

Could not find testhost.dll for source 'D:\Dev\Visual Studio 2017\CSharpSeven.NewFeatures\CSharpSeven.NewFeatures\CSharpSeven.Tests\bin\Debug\netstandard1.5\CSharpSeven.Tests.dll'. Make sure test project has a nuget reference of package "microsoft.testplatform.testhost".

My .csproj is the following:

<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netstandard1.5</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.TestPlatform.TestHost" Version="15.0.0" /> <PackageReference Include="System.ValueTuple" Version="4.3.0" /> <PackageReference Include="xunit" Version="2.2.0" /> <PackageReference Include="xunit.runner.console" Version="2.2.0" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\CSharpSeven\CSharpSeven.csproj" /> </ItemGroup> </Project> 

I've been struggling for quite sometime to get the tests running, can anyone please help?

2 Answers 2

1

Test projects needs to be runable applications. You need to target a specific runtime. For example:

 <PropertyGroup> <TargetFramework>netcoreapp1.1</TargetFramework> </PropertyGroup> 

See this answer for more information

Can't get XUnit tests to run with .NET Core

Sign up to request clarification or add additional context in comments.

Comments

1

Have you tried to do a restore and build first ?

dotnet restore dotnet build 

This should add any missing packages then you may run the tests.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.