Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NunitXml.TestLogger not recognized with --logger:nunit #23

Closed
mcblair opened this issue May 14, 2018 · 9 comments
Closed

NunitXml.TestLogger not recognized with --logger:nunit #23

mcblair opened this issue May 14, 2018 · 9 comments

Comments

@mcblair
Copy link

mcblair commented May 14, 2018

  1. Added NunitXml.TestLogger to dotnet SDK based Test project via Visual Studio nuget package manager.
  2. Ran dotnet test --test-adapter-path:. --logger:nunit
  3. Output:
    Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName 'nunit'.
@mcblair
Copy link
Author

mcblair commented May 14, 2018

I managed to consume NunitXml.TestLogger by using nuget.exe to install the package directly to the project directory and assigning --test-adapter-path to dir NunitXml.TestLogger.1.1.0.

Is this the intended setup? This is what the test csproj looks like:

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

  <PropertyGroup>
    <TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
    <RuntimeIdentifier>linux-x64</RuntimeIdentifier>   
    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.0.1" />
    <PackageReference Include="NetEscapades.Configuration.Yaml" Version="1.3.1" />
    <PackageReference Include="nunit" Version="3.10.1" />
    <PackageReference Include="NunitXml.TestLogger" Version="1.1.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
  </ItemGroup>

</Project>

Using nuget to install it directly only works on Windows.

@mcblair
Copy link
Author

mcblair commented May 14, 2018

Linux produces the same error:
Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName 'nunit'.

@mcblair
Copy link
Author

mcblair commented May 14, 2018

I have been able to pinpoint what is causing issues.

dotnet test --no-build --no-restore --test-adapter-path:src/NunitXml.TestLogger.1.1.0 --logger:nunit;LogFilePath=TestResultsCore.xml

It doesn't appear to be compatible with --no-build --no-restore.

@codito
Copy link
Collaborator

codito commented May 15, 2018

The logger assemblies are copied to output directory of project in build step (via https://github.com/Faizan2304/LoggerExtensions/blob/master/nuspec/NunitXml.TestLogger.props). I think this step didn't run with --no-build.

Is the intention to run dotnet build first and then dotnet test --no-build? It should work in this scenario ideally since the *.props file should have been triggered with dotnet build itself.

@codito
Copy link
Collaborator

codito commented May 15, 2018

Re #23 (comment)

Is this the intended setup?

The test project csproj looks right. It should contain a reference to logger package.

@mcblair
Copy link
Author

mcblair commented May 15, 2018

The particular library I am testing with this test project targets both netcoreapp2.0 and net461 - and so does the test project.

What this means for me is that I cannot use dotnet build, I must use mono's msbuild - it supports building dotnet standard/core and full frameworks. See this: https://stackoverflow.com/questions/44770702/build-nuget-package-on-linux-that-targets-net-framework

So what I have going on is

  1. msbuild /t:Restore
  2. msbuild /t:Build
  3. dotnet test --no-build --no-restore

I have tested doing this:

  1. msbuild /t:Restore
  2. msbuild /t:Build
  3. dotnet test -f netcoreapp2.0 --test-adapter-path:. --logger:nunit and this works
  4. dotnet test -f net461 --no-build --no-restore --test-adapter-path:. --logger:nunit and this fails with the System.Xml.XPath.XmlDocument error reported in Upgrade to NETStandard 2.0 needed to use System.Xml.XPath.XmlDocument #26

What I am currently doing until we can make progress is:

  1. msbuild /t:Restore
  2. msbuild /t:Build
  3. dotnet test -f netcoreapp2.0 --test-adapter-path:. --logger:nunit and tests run and pass, with results
  4. dotnet test -f net461 --no-build --no-restore and tests run and pass, but no results.

It allows me to leverage the results for things like Xray and Sonar based on the netcoreapp2.0 results. This is okay temporarily, because there are no differences between the net461 and netcoreapp2.0 implementations of the library i'm testing.

@codito
Copy link
Collaborator

codito commented May 16, 2018

Thanks for sharing more context.

Can you share the logs from below step? Let's see if mono's msbuild includes the logger nuget package props files in the build process.

2. msbuild /t:Build /v:diag > log.txt

@bchavez
Copy link

bchavez commented Dec 1, 2018

I encountered the same problem.

Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName 'nunit'

Here's how I fixed the issue:

  • Completely remove any direct calls to "MSBuild" via command-line from my build scripts and just stick to using dotnet build for all .NET Core/Standard builds.
  • Also, deleted all \bin and \obj in all project folders before invoking dotnet test again.
    • Issues can crop up if your migrating an old CSPROJ projects (using .NET Full Framework) to the new CSPROJ format. MSBuild can leave old deps and obj files that can confuse the heck out of dotnet.

Now everything works:

dotnet test --test-adapter-path:. --logger:"nunit;LogFilePath=test-result.xml"
Build started, please wait...
Build completed.

Test run for _____\bin\Debug\netcoreapp
Microsoft (R) Test Execution Command Line Tool Version 15.8.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
Results File: _____\test-result.xml

Total tests: 62. Passed: 45. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 1.3485 Seconds

🍫 🍪 🍭 Ronald Jenkees - Stay Crunchy

smeierzubiesen pushed a commit to TheNoviceProspect/SManager that referenced this issue Dec 4, 2020
smeierzubiesen pushed a commit to TheNoviceProspect/SManager that referenced this issue Dec 4, 2020
@codito
Copy link
Collaborator

codito commented Jan 28, 2021

Closing old issue.

@codito codito closed this as completed Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants