JetBrains / TeamCity.VSTest.TestAdapter

Apache License 2.0
30 stars 14 forks source link

dotnet test on solution returns can't find logger #33

Closed seertenedos closed 4 years ago

seertenedos commented 5 years ago

dotnet test -c Release --no-build -verbosity:normal ./U-BLT.sln

results in the following error for my 2+ unit test projects and i can't work out how to fix it.

Step 19/19 : RUN dotnet test -c Release --no-build -verbosity:normal ./U-BLT.sln
 ---> Running in 285fc0ff9e88
Build started 5/29/19 9:40:36 PM.
     1>Project "/src/U-BLT.sln" on node 1 (VSTest target(s)).
     1>ValidateSolutionConfiguration:
         Building solution configuration "Release|Any CPU".
Test run for /src/TestProjectToApplyDataFixes/bin/Release/netcoreapp2.2/TestProjectToApplyDataFixes.dll(.NETCoreApp,Version=v2.2)
Test run for /src/UnitTests/bin/Release/netcoreapp2.2/Dnb.Opal.Ublt.UnitTests.dll(.NETCoreApp,Version=v2.2)
Microsoft (R) Test Execution Command Line Tool Version 16.0.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Microsoft (R) Test Execution Command Line Tool Version 16.0.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName 'logger://teamcity/'.
Starting test execution, please wait...
Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName 'logger://teamcity/'.
     1>Done Building Project "/src/U-BLT.sln" (VSTest target(s)) -- FAILED.

Environment/setup I am using dotnet core 2.2 docker images. Building on linux. I am performing the tests as part of the docker build in case this affects anything and i am using

Basically i am trying to run all test projects on a solution in a docker build step on teamcity as something we would use for all our solutions going forward. I am doing it inside the docker build pipeline to take advantage of the multi image builds and caching in docker to greatly speed up the build especially for some of our bigger applications with many projects and nuget packages.

NikolayPianikov commented 5 years ago

@seertenedos could you make sure that these files:

IoC.dll
TeamCity.ServiceMessages.dll
TeamCity.VSTest.TestAdapter.dll
TeamCity.VSTest.TestLogger.dll

are in a directory like YourTestProject\bin\Release\netcoreapp2.2 before running a command like dotnet test -c Release --no-build

The option --no-build supposes that all binaries were already built and an output folder is ready to run tests.

Also try running your tests without the option --no-build.

seertenedos commented 5 years ago

@NikolayPianikov wow you were right. without --no-build it works.

Thanks to your help i have located the causeand it comes down to when you set ENV TEAMCITY_VERSION. Turns out it needs to be set before the build where as in the past i set it only before i ran the tests. eg

RUN dotnet build "U-BLT.sln" -c Release
ARG TEAMCITY_VERSION
ENV TEAMCITY_VERSION = $TEAMCITY_VERSION
RUN dotnet test -c Release --no-build -verbosity:normal ./U-BLT.sln

but

ARG TEAMCITY_VERSION
ENV TEAMCITY_VERSION = $TEAMCITY_VERSION
RUN dotnet build "U-BLT.sln" -c Release
RUN dotnet test -c Release --no-build -verbosity:normal ./U-BLT.sln

works and it also works without the --no-build I would have though it was the test that checks the env var but it actually looks like it is the build that does it. I can handle that but just makes things a little be more of a pain for reusable layers to prevent multiple builds of the same code.

I don't remember this being stated anywhere in the documentation and honestly it is not what i would expect.

NikolayPianikov commented 4 years ago

I've added notes under the demo video.

megakid commented 1 week ago

This ticket saved me tons of time! I hadn't built my project with TEAMCITY_VERSION, just ran the tests with it.