Visual Studio 2010不会发现新的单元测试 [英] Visual Studio 2010 does not discover new unit tests
问题描述
我正在Visual Studio 2010中编写一些单元测试.我可以使用在当前上下文中运行所有测试"来运行所有测试.
I am writing some unit tests in Visual Studio 2010. I can run all tests by using "Run all Tests in Current Context".
但是,如果我编写一个新的单元测试,则它不会被环境使用-换句话说,我无法通过运行所有测试或在其他任何地方在测试列表编辑器"中找到它.如果我卸载项目然后重新加载;新测试可以运行.
However, if I write a new unit test, it does not get picked up by the environment - in other words, I am not able to find it in Test List Editor, by running all tests, or anywhere else. If I unload the project and then reload it; the new test is available to run.
当我添加单元测试时,我只是向现有的TestClass添加一个新方法,并使用[TestMethod]属性对其进行修饰-没什么花哨的.
When I am adding a unit test, I simply add a new method to an already existing TestClass and decorating it with [TestMethod] attribute - nothing fancy.
什么可能导致此行为,如何使它起作用?
What might be causing this behaviour, and how do I make it work ?
推荐答案
我终于找到了问题所在.在测试工具"->测试项目"下的选项"中,有一个选项禁用测试方法的后台发现".它已打开-我不知道这是怎么发生的,但是删除复选标记并重新启动Visual Studio即可解决问题.
I finally figured out the problem. In Options under Test Tools -> Test Project, there is an option "Disable background discovery of test methods". It was turned on - I do not know how that happened, but removing the checkmark and restarting Visual Studio solved the problem.
这篇关于Visual Studio 2010不会发现新的单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!