3
votes

Unit tests run fine locally.

When run on the Visual Studio 2017 hosted build agent, the VSTest task fails with:

2018-12-08T10:42:16.3779907Z An exception occurred while invoking executor 'executor://mstestadapter/v2': Method 'get_Properties' in type 'Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestContextImplementation' from assembly 'Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50xx' does not have an implementation.
2018-12-08T10:42:17.7794385Z 

TestAdapter and TestPlatform libraries have been uninstalled and reinstalled (version 1.3.2) using Nuget Package Manager and no references to other versions of these libraries exist in the solution.

To simplify, all unit test projects except for a single one (targetting .NET Framework 4.6.1) have been removed from the solution.

What could be causing the VSTest task to fail in Azure Devops Build?

1
Are you using the Install Test Platform task to ensure an appropriate version of the VSTest platform is installed? docs.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/… - Daniel Mann
It's only necessary to use the Install Test Platform task, if the agent on which the build is running doesn't have Visual Studio installed. - René

1 Answers

0
votes

I had the same issue and I also tried all sorts of things, among them making sure that all versions were the same etc. Then I tried changing my tests from MSTest to NUnit (Including changing the test adapter from MSTest.TestAdapter to NUnit3TestAdapter) and then it worked.

So it seems it's a problem with the test adapter from Microsoft. I know it can be disruptive to change unit testing framework, so perhaps try a different version of the test adapter from Microsoft and see if that fixes the issue. It might just be a problem with the specific version you're using (I was using version 1.4.0).