Intro

In previous post I’ve shown you how to fix VSTest task in Azure DevOps. This post is follow up where I share with you how to overcome problems you might face while running vstest.console.exe.

Getting the vstest.console

You have to download nuget package https://www.nuget.org/packages/Microsoft.TestPlatform/ which contains vstest.console.exe under \tools\net451\Common7\IDE\Extensions\TestPlatform.

Here is a short vstest.console documentation https://docs.microsoft.com/en-us/visualstudio/test/vstest-console-options?view=vs-2019.

Running tests

Now to execute some tests, we have to pass our test dll to vstest.console and specify logger, in this case I want Visual Studio Test Results File(trx). This is actualy the same command, that VSTest task in Azure pipeline uses.

But what if running previous snippet, we get following output:

Hmm, strange, lets try to remove logger argument and run again:

and now we get following output:

Well, unfortunately I don’t have much experience using vstest.console and googling No suitable test runtime provider found for this run isn’t much helpful. I’ve spent many hours trying to figure this out with no luck. But every problem has it’s solution…

Fixing

In the end I’ve realized that vstest.console has /Diag argument which, accorging to documentation: "Writes diagnostic trace logs to the specified file."

Let’s rerun our test with /Diag argument:

Investigating diagnosting log, created by previous snippet C:\Data\diag.txt, I’ve found many FileLoadExceptions, first one of them being:

The exception is in fact very usefull, as it says: See http://go.microsoft.com/fwlink/?LinkId=155569 for more information. In a nutshell the problem is, that vstest.console is trying to load assembly that is from a remote location and that causes previous exception.

To fix that, we have to edit vstest.console.exe.config located in same folder as vstest.console.exe(in my case C:\Program Files\Microsoft Test Platform\Common7\IDE\Extensions\TestPlatform\vstest.console.exe.config). Open vstest.console.exe.config, add <loadFromRemoteSources enabled="true"/> under <runtime> element and save. See example config bellow:

After that you should be able to successfuly run tests using vstest.console.

Last modified: January 25, 2023
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments