TFS not deploying referenced assembly to test dir when on build server

后端 未结 1 1317
别那么骄傲
别那么骄傲 2021-01-03 03:18

I have Coded-UI test project that has references to other assemblies in solution. Somehow some assemblies are not copied to TestResults/Out directory, while oth

1条回答
  •  醉梦人生
    2021-01-03 03:59

    I've seen this before. Your test project references other projects but when the tests run you'll notice that the assemblies are not present in the TestRun Out folder.

    Unlike other test runners that run unit tests from a fixed location, MSTest copies the assemblies that it requires to a test run folder where the tests are executed. The design allows you to compare test results, coverage, outputs between test runs.

    The common misconception is that somehow compilation settings like "Copy Local" will somehow influence which dependencies are used for testing, which is simply not true. MSTest uses reflection to determine assembly references that are required for the test run.

    The error you are seeing is likely caused because you've referenced the assembly but the test assembly is not directly using it. You can verify this by using a IL inspection utility (DotPeek, Reflector, etc) to look at the test-assembly references. (This is often a problem in WPF projects that reference assemblies in the XAML.)

    To fix, either use the DeploymentSettings to copy the assembly to the output folder; or use the assembly in the test project. For example, adding the following to your test project will emit IL that ensures the assembly is deployed:

    var type = typeof(AssemblyNotBeingCopied.MyClass);
    

    0 讨论(0)
提交回复
热议问题