Thursday 10 September 2015

Dependent Assembly needed for MSTest Unit Testing Assembly

Problem

In my case, when testing an assembly that had a generated XmlSerializers assembly associated with it the unit tests would fail when loading the SUT assembly.  The problem was caused by the serializer assembly not being copied to the deployment location of the tests.

Solution

To get the serializer assembly to deploy you need to:

  1. Mark the test class or method with a DeploymentItem attribute like so [DeploymentItem("MySubjectAssembly.XmlSerializers.dll")]
  2. Change your solution's LocalTestRun.testrunconfig to include, in the Deployment section, the XmlSerializers.dll from the bin\debug folder of your test project.

No comments: