在 Visual Studio 2008 中更改单元测试项目的输出路径
我更改了测试项目的输出路径,因为默认路径不符合我们的项目目录结构。 执行此操作后,Visual Studio 2008 无法运行测试,因为它找不到单元测试项目程序集。
为了让单元测试引擎找到程序集,我还需要更改什么?
I changed the output path of the test project, because the default path doesn't conform to our projects directory structure. After I did that, Visual Studio 2008 fails to run the tests, because it can't find the Unit Test project assembly.
What else do I have to change for the Unit Test Engine to find the assembly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
至少有三种方法可以解决此问题
可能不推荐解决方案 3,因为解决方案 1 或 2 将实现相同的效果
无需添加对输出路径的第二个引用。
请注意,解决方案 2 将删除您可能拥有的所有测试历史记录。
There are at least three ways to solve this problem
Solution number 3 is probably not recommended, since solution 1 or 2 will achieve the same
without adding a second reference to the output path.
Please note that solution number 2 will delete any test history you may have.
如果打开 .testrunconfig 文件并转到“部署”选项,则可以将测试程序集添加到要部署的文件列表中。 然后您应该能够运行测试。
If you open up your .testrunconfig file and go to the Deployment option, you can add your test assembly to the list of files to deploy. You should then be able to run your tests.
我想我已经明白了这一点。
这是我找到的唯一解决方案。 将程序集添加到要部署的文件列表中(按照 Ty 的建议)是可行的,但感觉有点脏,所以我不想这样做。
仅当您在运行任何测试之前更改路径时,Visual Studio 才会接受更改的路径。 因此,我自己的问题的解决方案是:您必须创建一个新的测试项目,更改其构建路径,添加旧测试项目中的所有测试。
I figured this out, I think.
This is the only solution I have found. Adding the assembly to the files to deploy list (as suggested by Ty) works, but it kind of feels dirty, so I didn't want to do that.
Visual Studio accepts the changed path, only when you change it before running any of the tests. So, the solution to my own question is: You have to create a new test project, change it's build path, add all of the tests from the old test project.
关闭项目,然后删除隐藏的 .suo 文件和 csproj.user 文件。 然后重新打开项目。 这样就解决了。
Close your project, then delete your hidden .suo file and the csproj.user file. Then re-open the project. That fixes it.