JetBrains / TeamCity.VSTest.TestAdapter

Apache License 2.0
30 stars 14 forks source link

No output when run by TeamCity agent #36

Closed wattsm closed 4 years ago

wattsm commented 4 years ago

We are running xUnit tests using dotnet vstest as a part of our build process. The tests are being run by the agent but the results are not being reported. Looking at the raw agent logs it seems that no system messages are being emited.

However, I can log onto the build agent's machine as the user that the agent runs as, copy and paste the dotnet vstest command into cmd.exe and it will run the tests and emit system messages as expected.

Any suggestions on what is wrong in our setup gratefully received.

Team City version: TeamCity 2017.1.2 (build 46812)

Example DotNet command being used:

"C:\Program Files\dotnet\dotnet.EXE"  vstest "C:\TeamCity\Agent.1\buildAgent\work\6cbcd640b5d0f18b\build\work\Test.Assembly.dll" /Logger:TeamCity "/TestAdapterPath:C:\TeamCity\Agent.1\buildAgent\work\6cbcd640b5d0f18b\build\work"

(I have tried running this command as the agent user in cmd.exe from various working directories and it always works as expected.)

Output of dotnet --info:

.NET Core SDK (reflecting any global.json):
 Version:   3.1.100
 Commit:    cd82f021f4

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.100\

Host (useful for support):
  Version: 3.1.0
  Commit:  65f04fb6db

.NET Core SDKs installed:
  2.1.508 [C:\Program Files\dotnet\sdk]
  2.1.509 [C:\Program Files\dotnet\sdk]
  2.2.104 [C:\Program Files\dotnet\sdk]
  3.1.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
NikolayPianikov commented 4 years ago

xunit tests for .net core only sends tests statistics to TeamCity via service messages without any additional adapters, so you could avoid passing /Logger:TeamCity "/TestAdapterPath:C:\TeamCity\Agent.1\buildAgent\work\6cbcd640b5d0f18b\build\work" there

But there is an issue, so you should use the verbosity level at least normal adding the argument /logger:console;verbosity=normal like the following:

"C:\Program Files\dotnet\dotnet.EXE" vstest "C:\TeamCity\Agent.1\buildAgent\work\6cbcd640b5d0f18b\build\work\Test.Assembly.dll" /logger:console;verbosity=normal

Or you could update the TeamCity version and dotnet CLI runner will do it for you

NikolayPianikov commented 4 years ago

I've update the readme file

wattsm commented 4 years ago

Thanks @NikolayPianikov, removing the Team City logger from dotnet vstest has done the trick.

To clarify, when you say that .Net Core Xunit tests send statistics without any additional adapters, does this mean that they also do not require a reference to TeamCity.VSTest.TestAdapter in the test project?

NikolayPianikov commented 4 years ago

@wattsm Yes, you could remove that reference if you are planning to have dotnet core xunit test projects only. For instance xunit for full dotnet does not provide TeamCity integration from the box.

wattsm commented 4 years ago

Sounds good, thanks.