Vstest.console.exe ignore app.config

I have some problems with my app.config file in unit tests. It seems that vstest.console.exe is being ignored. When I run my unit test with MStest, there is no problem with the application config file.

The config file should fix some build issues (redirecting build versions). Here is the content of this file:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="RhinoCommon"
          publicKeyToken="552281e97c755530"
          culture="neutral" />
        <bindingRedirect oldVersion="5.1.30000.4" newVersion="5.1.30000.14"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

      

When I go into this code in machine.config, my unit tests are successfully redirected to use a different version of the assembly. But this way to solve my build problem doesn't work. The unit test project needs to run on the build server and this needs to be decided at the application level.

There is no information on the Internet about this problem. Based on this answer vstest.console.exe with / EnableCodeCoverage just "hangs" ... how to debug and how to fix? the app config can be added to vstest.executionengine.config (because this is actually running the exe), but it doesn't work for me and as I said this issue needs to be resolved at the app level.

There are no problems with app.config in MStest.exe, but it doesn't work in my situation.

Has anyone seen a problem like this? Any help would be appreciated.

+3


source to share


1 answer


By adding a file legacymode.runsettings

containing:

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <MSTest>
    <ForcedLegacyMode>true</ForcedLegacyMode>
  </MSTest>
</RunSettings>

      

You will force Mstest to run in legacy mode, but it will also revert the old assembly loading behavior and pick the settings from the app.config

test project.



You can also configure legacy mode for your build server by specifying the path .runsettings

in your source control repository in your build definition:

Setting the .runsettings file in the assembly definition

Image source

+1


source







All Articles