简体   繁体   English

ReSharper 没有运行新的单元测试

[英]ReSharper not running new unit tests

When I create new NUnit unit tests in my test project, the ReSharper Unit Test Runner detects them but they remain grey and are not run.当我在我的测试项目中创建新的 NUnit 单元测试时,ReSharper 单元测试运行器会检测到它们,但它们保持灰色并且不会运行。

This behaviour occurs whether I try to run the tests individually or all together.无论我尝试单独运行测试还是一起运行测试,都会发生此行为。

If I close and reopen the solution, the new tests are detected and run correctly.如果我关闭并重新打开解决方案,则会检测到新测试并正确运行。

The behaviour only occurs if I build the solution using Visual Studio before I run the tests.仅当我在运行测试之前使用 Visual Studio 构建解决方案时才会出现该行为。 If I let ReSharper trigger the build, the tests are detected correctly.如果我让 ReSharper 触发构建,则会正确检测到测试。

I am using:我在用:

  • Visual Studio 2010视觉工作室 2010
  • ReSharper锐化
  • NUnit 2.5.7 NUnit 2.5.7

它还帮助我公开单元测试类:D

Try cleaning the solution and delete RS related files and folders from your project folder.尝试清理解决方案并从项目文件夹中删除与 RS 相关的文件和文件夹。 It has worked for me.它对我有用。 I use VS2008 though.不过我用的是VS2008。

Unit test methods must be public .单元测试方法必须是 public

This test will not be recognized:此测试将不被识别:

[Test]
void RunTest(){
    Assert.True;
}

Whereas this test is recognized:而这个测试被认可:

[Test]
public void RunTest(){
    Assert.True;
}

Ran into this while using specflow.在使用 specflow 时遇到了这个问题。 New project > nuget specflow then I added spec (nunit) tests.新项目 > nuget specflow 然后我添加了规范(nunit)测试。 Then I received the error.然后我收到了错误。 Merely restarting my only running visual studio 2012 instance fixed the issue.仅重新启动我唯一运行的 Visual Studio 2012 实例即可解决该问题。

I've seen this issue.我见过这个问题。 In my specific case, it was due to building my code to a network drive lacking Full Trust.在我的特定情况下,这是由于将我的代码构建到缺乏完全信任的网络驱动器。

Although VS is happy to build and run from there - NUnit was not happy.尽管 VS 很高兴从那里构建和运行 - NUnit 并不高兴。 Unhelpfully it doesn't display any reason for the failure (just those unexplained grey dots by the test names)无益的是它没有显示任何失败的原因(只是测试名称那些无法解释的灰点)

Just ran into this today using VS 12, NUnit and RS 8.2.今天刚刚使用 VS 12、NUnit 和 RS 8.2 遇到了这个问题。 There is a setting on the Unit Test Session console for Build Settings.单元测试会话控制台上有一个用于构建设置的设置。 Make sure it is set to Automatic NOT Automatic (Whole Solution).确保将其设置为自动而非自动(整体解决方案)。

I ran into the same issue.我遇到了同样的问题。 I am running VS2013 with ReSharper 8.2.3.我正在使用 ReSharper 8.2.3 运行 VS2013。 Cleaning and rebuilding the solution did not resolve the error.清洁和重建解决方案没有解决错误。

My test method was async but returned void .我的测试方法是async但返回了void Returning a Task fixed the error.返回Task修复了错误。

Also make sure you actually have the [Test] annotation or [TestCase(...)] annotation on your method.还要确保您的方法上确实有 [Test] 注释或 [TestCase(...)] 注释。 If that is not there, then you definitely won't see the test in the list.如果那不存在,那么您肯定不会在列表中看到测试。

I got a similar issue fixed installing the NuGet NUNitTestAdapter.我在安装 NuGet NUItTestAdapter 时遇到了类似的问题。

I am using NUnit v.2.6.4 and the NUnitTestAdapter v2.1.1 did the trick.我使用的是 NUnit v.2.6.4,而 NUnitTestAdapter v2.1.1 成功了。

Deleting the _ReSharper folder and the ReSharper CACHE file did not fix the issue for me.删除_ReSharper文件夹和 ReSharper CACHE文件并没有解决我的问题。

I had this issue today where ReSharper would not run the unit tests, and I fixed the problem by running Clean Solution and then rebuilding the solution.我今天遇到了这个问题,ReSharper 不会运行单元测试,我通过运行Clean Solution然后重建解决方案来解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM