Coould not run xunit tests for two frameworks in one project
See original GitHub issueSteps to reproduce
I have this csproj
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
<PropertyGroup>
<TargetFrameworks>net46;netcoreapp1.0</TargetFrameworks>
<AssemblyName>ProjectName</AssemblyName>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk">
<Version>1.0.0-alpha-20161104-2</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk">
<Version>15.0.0-preview-20161123-03</Version>
</PackageReference>
<PackageReference Include="xunit">
<Version>2.2.0-beta4-build3444</Version>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio">
<Version>2.2.0-beta4-build1194</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<PackageReference Include="Microsoft.NETCore.App">
<Version>1.0.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.Portable.Compatibility">
<Version>1.0.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.TestPlatform.TestHost">
<Version>15.0.0-preview-20161123-03</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Expected behavior
dotnet test --framework net46 dotnet test --framework netcoreapp1.0
Actual behavior
dotnet test --framework net46 - works fine dotnet test --framework netcoreapp1.0 - does not work. I got an error
Starting test execution, please wait...
Error: Could not find testhost.dll for source 'C:\Projects\ProjectName\bin\Debug\netcoreapp1.0\ProjectName.dll'. Make sure test project has a nuget reference of package "microsoft.testplatform.testhost".
Environment data
.NET Command Line Tools (1.0.0-preview4-004123)
Product Information: Version: 1.0.0-preview4-004123 Commit SHA-1 hash: 3a3ab7e0b0
Runtime Environment: OS Name: Windows OS Version: 10.0.14393 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\1.0.0-preview4-004123
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:20 (11 by maintainers)
Top Results From Across the Web
Coould not run xunit tests for two frameworks in one project
Steps to reproduce. I have this csproj · Expected behavior. dotnet test --framework net46 · Actual behavior. dotnet test --framework net46 - works ......
Read more >How to properly unit test a .NET project with multiple target ...
First, test projects can multi-target as well by making use of the <TargetFrameworks> property just like you used for the library.
Read more >Running Tests in Parallel
Parallelism in Test Frameworks Tests written in xUnit.net version 1 cannot be run in parallel against each other in the same assembly, though...
Read more >XUnit tests do not run in solution
The problem is specifically with XUnit test projects, because NUnit and MsTest projects run tests normally. All the packages in XUnit project ......
Read more >How To Resolve Issue Of Test Project Not Running The ...
Two of my test projects didn't run the test cases, it was about to start and took some time to run the test...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve added these two lines and it started working
As of 87e9815a25a29fbfa8b87b5757bd44075ef6df4a,
Microsoft.NET.Test.Sdk
can handleOutputType
mismatch between netcoreapp and net4x targets. There is no need to specifyOutputType
in the test project csproj.Please try build/test with latest dotnet-cli dev build.