在visual studio中运行单元测试时出错:缺少测试用例对象

时间:2021-10-09 15:38:41

I'm getting the following error when running unit tests from visual studio using resharper:

使用resharper从visual studio运行单元测试时出现以下错误:

Test-case objects missing for the following elements: ... Rebuild the project and try again

以下元素缺少测试用例对象:...重建项目并重试

In the tooltip next to the unit test method it says: Inconclusive: Test not run and I think it said Unit test skipped at one point. Resharper shows a grey eye icon.

在单元测试方法旁边的工具提示中,它说:不确定:测试没有运行,我认为单元测试跳过了一点。 Resharper显示灰色眼睛图标。

There's also a wierd issue with visual studio's Test Explorer. It won't show all my unit tests. In fact, it's missing over 200 of my unit tests. They just don't appear in the Test Explorer window. I do have a handful of tests that appear and will run just fine.

Visual Studio的Test Explorer也存在一个奇怪的问题。它不会显示我的所有单元测试。事实上,它缺少200多个单元测试。它们只是没有出现在Test Explorer窗口中。我确实有一些测试出现并且运行得很好。

Things I've tried already: rebooting my machine, clean, rebuild, changing all dependent projects to use the same .net framework 4.7.

我已经尝试过的事情:重新启动我的机器,清理,重建,更改所有依赖项目以使用相同的.net框架4.7。

I'm using VS 2017 .net Framework 4.7, Resharper, and MSTest. All with the latest updates and versions.

我正在使用VS 2017 .net Framework 4.7,Resharper和MSTest。全部包含最新的更新和版本。

3 个解决方案

#1


5  

I know this won't answer the OP's question, since he/she has tried it, but maybe it will help someone else.

我知道这不会回答OP的问题,因为他/她已经尝试过,但也许它会帮助别人。

For me a simple restart of Visual Studio solved the Test-case objects missing for the following elements: ... Rebuild the project and try again problem.

对我来说,Visual Studio的简单重启解决了以下元素缺少的测试用例对象:...重建项目并再次尝试问题。

#2


4  

I experienced this error after removing all nuget packages as i had changed my .net version and did not need any of them to compile.

删除所有nuget包之后我遇到了这个错误,因为我已经更改了我的.net版本,并且不需要任何编译。

after re-installing MSTest.TestAdapter nuget package re-sharper started running my unit tests again as expected

重新安装MSTest.TestAdapter后,nuget包re-sharper开始按预期再次运行我的单元测试

Install-Package MSTest.TestAdapter

安装包MSTest.TestAdapter

#3


0  

After banging my head for a day I got Test Explorer working. It was the target Platform.

在敲了一天头后,我让Test Explorer工作了。它是目标平台。

In the unit test project properties, under Build, I had the Platform target as x64. I switched it to AnyCPU and Test Explorer immediately picked up my missing unit tests. However, resharper is still giving me the same error. I'll update if I find solution for it. In the mean time, I can at least run and debug my unit tests now.

在单元测试项目属性中,在Build下,我将Platform目标设为x64。我把它切换到AnyCPU,测试资源管理器立即拿起我缺少的单元测试。然而,resharper仍然给我同样的错误。如果我找到解决方案,我会更新。与此同时,我至少可以运行和调试我的单元测试。

#1


5  

I know this won't answer the OP's question, since he/she has tried it, but maybe it will help someone else.

我知道这不会回答OP的问题,因为他/她已经尝试过,但也许它会帮助别人。

For me a simple restart of Visual Studio solved the Test-case objects missing for the following elements: ... Rebuild the project and try again problem.

对我来说,Visual Studio的简单重启解决了以下元素缺少的测试用例对象:...重建项目并再次尝试问题。

#2


4  

I experienced this error after removing all nuget packages as i had changed my .net version and did not need any of them to compile.

删除所有nuget包之后我遇到了这个错误,因为我已经更改了我的.net版本,并且不需要任何编译。

after re-installing MSTest.TestAdapter nuget package re-sharper started running my unit tests again as expected

重新安装MSTest.TestAdapter后,nuget包re-sharper开始按预期再次运行我的单元测试

Install-Package MSTest.TestAdapter

安装包MSTest.TestAdapter

#3


0  

After banging my head for a day I got Test Explorer working. It was the target Platform.

在敲了一天头后,我让Test Explorer工作了。它是目标平台。

In the unit test project properties, under Build, I had the Platform target as x64. I switched it to AnyCPU and Test Explorer immediately picked up my missing unit tests. However, resharper is still giving me the same error. I'll update if I find solution for it. In the mean time, I can at least run and debug my unit tests now.

在单元测试项目属性中,在Build下,我将Platform目标设为x64。我把它切换到AnyCPU,测试资源管理器立即拿起我缺少的单元测试。然而,resharper仍然给我同样的错误。如果我找到解决方案,我会更新。与此同时,我至少可以运行和调试我的单元测试。