markvincze / MsTestTrxLogger

Logger implementation for vstest.console.exe that replicates the TRX format of mstest.exe.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using as part of a commandline build with TestAdapterPath argument

robertbird opened this issue · comments

Hi there,

First of all I just want to say that this is fantastic, you have saved the day for me. I have been having a nightmare getting Specflow reports to render properly for a new project with the latest version of Specflow (2.4.0) and other test libraries. I started with XUnit, then NUnit before falling back to MSTest and none of them worked until I found this. So thanks a ton for putting this out there.

I am trying to generate a report using a command-line build script, using VSTest to run tests. I was setting the TestAdapterPath parameter to point to a folder containing the dll but was unable to load the assembly with the error: "Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName 'MsTestTrxLogger'".

I came across this Stack Overflow post: https://stackoverflow.com/questions/49380404/could-not-find-vstest-test-logger-with-uri-or-friendlyname which says that the dll needs to end with the name "testlogger.dll".

This works. I tried renaming the dll, which then threw an error (System.IO.FileNotFoundException: Could not load file or assembly 'MsTestTrxLogger, Version=1.3.0.0,), so I now have it working perfectly (as a workaround) by having two copies of the dll in the folder.

So..... I know this is going to cause a breaking change for people following this and upgrading, but what is the chance of renaming the project and resulting dll?

Hi @robertbird,

Thanks for the detailed description of the issue. I actually haven't used this dll in a while, but I remember that making vstest.console.exe properly find the dll can be a nightmare, and the diagnostics messages are not too helpful either.

I would like to avoid renaming the dll and the assembly to testlogger.dll as long as we can, mainly because that would clash if someone else has a different test logger implementation, and tries to use the same workaround.

I'll try to dig into this a bit to try to figure out if we can find some way to always get this working reliably without the rename.

@robertbird Oh, scratch my previous comment. If it only needs the dll name to end with testlogger, that I can live with 🙂. Let me play with this a bit, and get back to you.

@robertbird, I played with this a bit, and managed to get it to work. What I did:
Without copying the dll, I ran

vstest.console.exe MyTests.dll /Logger:MsTestTrxLogger /Diag:vstestdiag.txt

I got the error Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName 'MsTestTrxLogger'., but this way the tool writes some diag messages into the file vstestdiag.txt.
In that file, there are lines like

TpTrace Information: 0 : 20488, 1, 2018/09/25, 19:27:30.918, 4350688525912, vstest.console.exe, AssemblyResolver.AddSearchDirectories: Adding more searchDirectories C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\TestPlatform\Extensions,C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\TestPlatform

So I took the path from there, and copied the dll exactly into C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\TestPlatform\Extensions. After doing this, the command

vstest.console.exe TestLogger.dll /Logger:MsTestTrxLogger

works fine.

Some questions:

  • What VS version do you have?
  • Where did you try to copy the dll exactly?
  • If you do the same test with /Diag, what extension path does it print, and what happens if you copy the dll exactly there?

Closing due to inactivity.