MSTest Not Finding New Tests

风格不统一 提交于 2019-11-29 05:59:09

Simplest way: Reopen the solution.

You can also open your test list file (the "vsmdi" file in your Solution Items folder) and hit the "refresh" button there.

A full rebuild of your solution works sometimes, too.

I ran into the same problem with not discovering new test methods after I had uninstalled ReSharper and updated to Visual Studio 2010 SP1.

I fixed the issue by going to Tools > Options > Test Tools > Test Project and unchecked "Disable background discovery of test methods".

It worked re-opening the solution but not doing a full clean and rebuild.

For me nothing of the above worked. I compared my csproj file with one that worked and added the project type guids from the other test project to the one that didn't work.

So try to add the type Guids to your project file where the [TestClass] and [TestMethod] is included with a text editor:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
...
    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    </PropertyGroup>
...
</Project>

After adding this and a refresh in the test list editor I instantly saw my tests and CTRL-R-T worked.

Regards, Michael

Make sure your tests have prefixes such as [TestClass] for the class and [TestMethod] for the methods. I had a case where I did not realize that I was trying to run tests written in another framework. In my case it was [TestFixture] and [Test].

Deleting the file with the extension '.sln.docstates' that is in the project folder fixed the issue for me.

Not sure if it matters - but I also deleted all the files in the TestResults folder.

Athadu

For me, delete of .suo and .sdf files related to the solution helped. Right after reopening the solution, the tests were in the List Editor.

I had this problem and the solution was embarrassingly simple: Mark the class as public. The test class I created did not have the public access modifier.

A look at the test output window told me everything I needed to know.

Test Output Window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!