TFS UnitTesting 在构建服务器上不部署本地副本程序集来测试目录 [英] TFS UnitTesting not deploying local copy assembly to test dir when on build server

查看:23
本文介绍了TFS UnitTesting 在构建服务器上不部署本地副本程序集来测试目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序集,它需要在测试输出目录中才能运行我的测试.我在项目中将程序集引用为本地副本,但在构建服务器上这被忽略了.我发现解决此问题的两种方法是

I have an assembly that needs to be in the test output dir for my tests to run. I have the assembly referenced as a local copy in the project but on the build server this gets ignored. The two ways I have found to fix this are

  1. 向测试方法添加一个特殊属性,以确保每个测试都有该文件.

  1. Add a special attribute to test method that will make sure the file is there for each test.

[DeploymentItem("我的程序集")]

[DeploymentItem("my assembly")]

这不是很实用,因为这个程序集几乎在程序集中的每个测试中都是必需的.

This is not very practical as this assembly is required for almost every test in the assembly.

添加带有特殊部署部分的测试运行配置文件.我在我的构建脚本中使用 TestContainer 来运行测试我认为这可能是我包含的测试运行配置没有被选中并且程序集没有被复制的原因.我不想有 vsmdi 测试列表文件,因为我正在尝试运行所有测试,我觉得这会违反 DRY.

Add test run config file with special deployment section. I am using a TestContainer in my build scripts to run the tests I think that this may be the reason my included test run config does not get picked up and the assembly not copied. I would prefer to not have a vsmdi test list file as I am trying to run all tests and I feel this would be a violation of DRY.

关于如何让我的测试运行有什么建议吗?

Any suggestions on how I can get my tests running?

推荐答案

当我的程序集被动态加载时,单元测试框架没有复制它.我通过在程序集中的一个类型上调用 typeof 向它添加了一个显式引用,一切都很好.

As my assembly was being dynamicly loaded the unit test framework was not copying it. I added a explict refrence to it by calling typeof on one of the types in the assembly and all is fine.

感谢 Jerome Laban 在这方面的帮助.

Thanks Jerome Laban for your help with this one.

这篇关于TFS UnitTesting 在构建服务器上不部署本地副本程序集来测试目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆