7

我在我的 Visual Studio 中遇到了这种不寻常的行为,突然我的测试二进制文件(mytestsolution.dll)和在引用中添加的依赖二进制文件被从我的 Bin 文件夹复制到 TestResults\\Out 文件夹并开始执行那里?

这导致我的测试失败,因为我的 GetExecutionAssembly() 给出了 Out 文件夹的路径,而不是存在一些依赖二进制文件的 Bin 文件夹?

任何人都可以帮助我如何阻止这种情况吗?

4

5 回答 5

4

Visual Studio 2010 creates a folder TestResults and deploys all relevant files in subdirectories with the following schema: username_computername date time.

This is the normal behavior if you don't have a .testsettings file for your solution. The .testsettings file is situated in folder Solution Items.

If you have a .testsettings file, it depends on the setting of Enable Deployment in the Deployment section. If Enable Deployment is checked, the TestResults folder will be created and filled.

enter image description here

In some cases it is possible that the TestResults folder will be created although Enable Deployment is deactivated. But in this case the folder is used only for some temporary files, not for the execution files of your tests.

For more infos see:

MSDN - Test Deployment Overview

于 2014-09-05T12:26:53.657 回答
4

参加聚会有点太晚了,但在这里我刚刚从实验中学到了什么

环境:net45、VS2017、Microsoft.VisualStudio.QualityTools.UnitTestFramework

当 my TestMethodhasDeploymentItemAttribute时,它从TestResults\....\Out文件夹执行。当我删除DeploymentItemAttribute它时,它会从bin\debug.

于 2020-02-19T05:44:22.977 回答
1

这是 MSTest 的默认行为。解决方案编译后,测试运行程序将直接引用复制到 TestResults\_TestRun_\Out 文件夹。更改编译设置 (CopyLocal) 不会影响测试运行。

如果您有需要但不在 TestRun 输出文件夹中的依赖项,您有几个选项:

  1. 在测试程序集中添加对这些程序集的引用。由于测试运行程序使用反射来确定依赖关系,因此您需要在该程序集中引用一个类。

  2. 修改当前的测试设置并将依赖项作为部署项包括在内。

于 2013-02-13T00:09:50.900 回答
0

您可以通过在测试运行配置中禁用部署来修复此行为。例如,在 VS 2008 中:测试 > 编辑测试运行配置 > 本地测试运行 > 部署 > 启用部署 = 关闭。

有关更多详细信息,请参阅测试部署概述

于 2014-02-28T18:16:05.113 回答
0

将属性更改Copy LocalFalse

  1. 右键单击mytestsolution.dll,然后单击Properties
  2. 从那里更改Copy Local为假
  3. 构建解决方案并立即检查。
于 2013-02-11T13:42:51.950 回答