spekt / xunit.testlogger

XUnit logger for vstest platform
MIT License
73 stars 15 forks source link

Xunit and JUnit test adapter conflict #36

Closed ghost closed 2 years ago

ghost commented 2 years ago

Hello, I have a CI pipeline requiring test results in xunit and junit format. When I install both adapters to a project, xunit becomes unavailable Please check the example solution. I'm not sure if it is the desired behavior or is there a way how to specify xunit logger that I just don't know. macOS BigSur 11.5.2, .Net5 Error message:

dotnet test --logger xunit

  Determining projects to restore...
  All projects are up-to-date for restore.
  XUnitTestProject -> /Users/andrey/Programming/CoverGo/TestAdapterConflict/XUnitTestProject/bin/Debug/net5.0/XUnitTestProject.dll
Test run for /Users/andrey/Programming/CoverGo/TestAdapterConflict/XUnitTestProject/bin/Debug/net5.0/XUnitTestProject.dll (.NETCoreApp,Version=v5.0)
Microsoft (R) Test Execution Command Line Tool Version 16.8.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName 'xunit'.

If I remove package JunitXml.TestLogger, all is fine. The same behavior is observed even without package reference to Junit, but just the Junit dll presented in the output folder together with XUnit. I run into this situation when JUnit dll is copied from a referenced project.

codito commented 2 years ago

@andrey-covergo thank you for reporting this issue.

We're observing below exception possibly because of mismatch in common testlogger versions:

TpTrace Warning: 0 : 6436, 1, 2021/09/23, 20:52:40.473, 1738604030407, vstest.console.dll, TestPluginDiscoverer: Failed to get types from assembly 'Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestLogger, Version=3.0.66.0, Culture=neutral, PublicKeyToken=null'.  Skipping test extension scan for this assembly.  Error: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Method 'Serialize' in type 'Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestLogger.XunitXmlSerializer' from assembly 'Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestLogger, Version=3.0.66.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.TestPluginDiscoverer.GetTestExtensionsFromAssembly[TPluginInfo,TExtension](Assembly assembly, Dictionary`2 pluginInfos)
System.TypeLoadException: Method 'Serialize' in type 'Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestLogger.XunitXmlSerializer' from assembly 'Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestLogger, Version=3.0.66.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
TpTrace Warning: 0 : 6436, 1, 2021/09/23, 20:52:40.473, 1738604031235, vstest.console.dll, LoaderExceptions: System.TypeLoadException: Method 'Serialize' in type 'Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestLogger.XunitXmlSerializer' from assembly 'Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestLogger, Version=3.0.66.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
codito commented 2 years ago

v3.0.70 is pushed to nuget with a fix for this issue.