JetBrains / TeamCity.VSTest.TestAdapter

Apache License 2.0
30 stars 14 forks source link

Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName 'teamcity'. #32

Closed cschyma closed 5 years ago

cschyma commented 5 years ago

Could be in connection to https://github.com/JetBrains/TeamCity.VSTest.TestAdapter/issues/31, but is not working even with "TeamCity.VSTest.TestAdapter" Version="1.0.15".

dotnet --list-sdks
2.0.0 [C:\Program Files\dotnet\sdk]
2.1.104 [C:\Program Files\dotnet\sdk]
2.1.201 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.300 [C:\Program Files\dotnet\sdk]
2.1.401 [C:\Program Files\dotnet\sdk]
2.1.402 [C:\Program Files\dotnet\sdk]
2.1.503 [C:\Program Files\dotnet\sdk]
2.1.505 [C:\Program Files\dotnet\sdk]
2.1.602 [C:\Program Files\dotnet\sdk]
2.2.103 [C:\Program Files\dotnet\sdk]
2.2.105 [C:\Program Files\dotnet\sdk]
  1. dotnet new xunit
  2. dotnet add package TeamCity.VSTest.TestAdapter
  3. dotnet test --logger teamcity --test-adapter-path .

Results in

Build started, please wait...
Build completed.

Test run for C:\workspace\teamcitytest\bin\Debug\netcoreapp2.2\teamcitytest.dll(.NETCoreApp,Version=v2.2)
Microsoft (R) Test Execution Command Line Tool Version 15.9.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName 'teamcity'.
$ cat teamcitytest.csproj
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
    <PackageReference Include="TeamCity.VSTest.TestAdapter" Version="1.0.15" />
    <PackageReference Include="xunit" Version="2.4.0" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
  </ItemGroup>

</Project>
NikolayPianikov commented 5 years ago

@cschyma It is not so good idea to specify arguments --logger teamcity --test-adapter-path . there. The path . means just a current working directory. But your current working directory does not contain any adapters` assemblies.

Just use the command dotnet test to run tests.

To check TeamCity integration you could specify some TeamCity version via the environment variable SET TEAMCITY_VERSION=2018.2 (to simulate running under TeamCity, but it is not needed when you are running tests in TeamCity because it does it by itself) and run tests. The TeamCity adapter is in active mode when it detects the running under TeamCity, otherwise he tries to minimize his influence on stdOut.

Thus you script to check TeamCity integration from the command line could be like:

dotnet new xunit
dotnet add package TeamCity.VSTest.TestAdapter
SET TEAMCITY_VERSION=2018.2
dotnet test
cschyma commented 5 years ago

Thanks! Now it's working!

The documentation at 'VSTest Console' says:

To run tests from the command line, use additional command line arguments: /TestAdapterPath:., /Logger:teamcity

That's why I tried it that way. An automatic resolution via the environment is much better of course.