Visual Studio 2017 does not detect unit tests

I run .NET Framework 4.6.1to create a library of test classes, where I build tests MSTest( Microsoft.VisualStudio.TestTools.UnitTesting). I can do tests fine by going to the folder containing the test project and running it dotnet test.

However, VS does not detect tests in the text explorer. I updated every single NuGet package to the latest, as recommended in some answer to this problem:

enter image description here

I also tried both Test -> Test Settings -> Default Processor Architecture -> x86and x64.

I always get the following error:

[1/10/2018 5:01:03 PM Warning] The test run will use the DLL (s) created for Framework Framework45 and the X86 platform. The following dlls will not be part of the run:

? , .

Microsoft.AspNetCore 1.1.2.

: csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>    
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="CsvHelper" Version="6.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.1" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
    <PackageReference Include="Microsoft.VisualStudio.TestPlatform" Version="14.0.0.1" />
    <PackageReference Include="Moq" Version="4.7.99" />
    <PackageReference Include="MSTest.TestAdapter" Version="1.2.0" />
    <PackageReference Include="MSTest.TestFramework" Version="1.2.0" />
    <PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\CommonHelpers\CommonTestHelpers.csproj" />
    <ProjectReference Include="..\ks-systems\ks-systems.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
  </ItemGroup>

</Project>

2:

, x86/x64 .csproj. x86 - . 56 :

: cm-tools.Tests.Services.TripScholarshipServiceTest. : System.BadImageFormatException: 'CtsPlatform, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null' . .

, , , dotnet test , .

+4

Source: https://habr.com/ru/post/1692009/


All Articles