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

2

6

I am trying create a nunit test results xml file and attach it to a test run of my build in dev ops. I have the NUnit3TestAdapter.3.13.0 package installed in my test project and reference this in console options of the VS test task (test task is version 2).

packages.config: enter image description here

enter image description here

I have tried various combinations in the "other console options" field including "/TestAdapterPath:." or not stating the test adapter path at all. I have also tried moving the test adapter part into the "path to custom test adapters" field as "$(Build.SourcesDirectory)\packages\NUnit3TestAdapter.3.13.0\build\net35". However, each time the tests task returns the error:

Microsoft (R) Test Execution Command Line Tool Version 16.9.1
Copyright (c) Microsoft Corporation.  All rights reserved.
vstest.console.exe "C:\VSTSBuild\agentB\_work\2\s\SomeService.Tests\bin\SomeService.Tests.dll"
/Settings:"C:\VSTSBuild\agentB\_work\_temp\41oiukcwga4.tmp.runsettings"
/EnableCodeCoverage
/Logger:"trx"
/TestAdapterPath:"C:\VSTSBuild\agentB\_work\2\s"
/logger:nunit /TestAdapterPath:C:\VSTSBuild\agentB\_work\2\s\packages\NUnit3TestAdapter.3.13.0\build\net35
Starting test execution, please wait...
##[error]Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName 'nunit'.
Inherent answered 27/7, 2021 at 9:23 Comment(0)
L
11

That same error was solved on my end by adding a reference to this NuGet package:

NunitXml.TestLogger

Its description is: Xml logger for NUnit v3 compliant xml report when test is running with "dotnet test" or "dotnet vstest".

Lurleen answered 22/9, 2021 at 21:6 Comment(3)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewBrianabriand
I have been running this as a PR build. The only changes in my PR are adding test categories: [TestFixture(Category = "UnitTest")] and the NunitXml.testLogger package - which has made changes in my packages.config: <package id="NunitXml.TestLogger" version="3.0.97" targetFramework="net462" /> and csproj of my test project: <Import Project="..\packages\NunitXml.TestLogger.3.0.97\build\net45\NUnitXml.TestLogger.props" Condition="Exists('..\packages\NunitXml.TestLogger.3.0.97\build\net45\NUnitXml.TestLogger.props')" />Inherent
Would it make a difference if I checked in the NunitXml.TestLogger, then edited the build as in my original screen shot and then run a build (ie not from a PR)?Inherent
L
4

I encounter the same issue for Xunit. You need to add package XunitXml.TestLogger

Loam answered 12/9, 2023 at 18:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.