ReSharper 未运行新的单元测试

发布于 2024-11-08 13:14:14 字数 322 浏览 0 评论 0原文

当我在测试项目中创建新的 NUnit 单元测试时,ReSharper 单元测试运行程序会检测到它们,但它们保持灰色并且不会运行。

无论我尝试单独运行测试还是一起运行测试,都会发生此行为。

如果我关闭并重新打开解决方案,则会检测到新测试并正确运行。

仅当我在运行测试之前使用 Visual Studio 构建解决方案时,才会出现此行为。如果我让 ReSharper 触发构建,测试就会被正确检测到。

我正在使用:

  • Visual Studio 2010
  • ReSharper
  • NUnit 2.5.7

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.

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. If I let ReSharper trigger the build, the tests are detected correctly.

I am using:

  • Visual Studio 2010
  • ReSharper
  • NUnit 2.5.7

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

狼性发作 2024-11-15 13:14:14

尝试清理解决方案并从项目文件夹中删除 RS 相关文件和文件夹。它对我有用。不过我用的是VS2008。

Try cleaning the solution and delete RS related files and folders from your project folder. It has worked for me. I use VS2008 though.

热鲨 2024-11-15 13:14:14

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

It also helped me to make the unit test class public :D

┊风居住的梦幻卍 2024-11-15 13:14:14

单元测试方法必须是公开的

该测试将不被认可:

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

而该测试会被认可:

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

Unit test methods must be public.

This test will not be recognized:

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

Whereas this test is recognized:

[Test]
public void RunTest(){
    Assert.True;
}
倾听心声的旋律 2024-11-15 13:14:14

在使用specflow时遇到了这个问题。新项目>> nuget specflow 然后我添加了规范(nunit)测试。然后我收到了错误。只需重新启动我唯一正在运行的 Visual Studio 2012 实例即可解决该问题。

Ran into this while using specflow. New project > nuget specflow then I added spec (nunit) tests. Then I received the error. Merely restarting my only running visual studio 2012 instance fixed the issue.

天邊彩虹 2024-11-15 13:14:14

我见过这个问题。在我的具体情况下,这是由于将我的代码构建到缺乏完全信任的网络驱动器上。

尽管 VS 很乐意从那里构建和运行 - NUnit 却不高兴。毫无帮助的是,它没有显示任何失败的原因(只是测试名称中那些无法解释的灰点)

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. Unhelpfully it doesn't display any reason for the failure (just those unexplained grey dots by the test names)

迷路的信 2024-11-15 13:14:14

今天刚刚使用 VS 12、NUnit 和 RS 8.2 遇到了这个问题。单元测试会话控制台上有一个用于构建设置的设置。确保将其设置为“自动”而不是“自动”(整个解决方案)。

Just ran into this today using VS 12, NUnit and 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).

‖放下 2024-11-15 13:14:14

我遇到了同样的问题。我正在使用 ReSharper 8.2.3 运行 VS2013。清理并重建解决方案并未解决该错误。

我的测试方法是async,但返回void。返回 Task 修复了错误。

I ran into the same issue. I am running VS2013 with ReSharper 8.2.3. Cleaning and rebuilding the solution did not resolve the error.

My test method was async but returned void. Returning a Task fixed the error.

忆悲凉 2024-11-15 13:14:14

还要确保您的方法上确实有 [Test] 注释或 [TestCase(...)] 注释。如果不存在,那么您肯定不会在列表中看到该测试。

Also make sure you actually have the [Test] annotation or [TestCase(...)] annotation on your method. If that is not there, then you definitely won't see the test in the list.

沉默的熊 2024-11-15 13:14:14

我在安装 NuGet NUUnitTestAdapter 时遇到了类似的问题。

我正在使用 NUnit v.2.6.4 和 NUnitTestAdapter v2.1.1 做到了这一点。

I got a similar issue fixed installing the NuGet NUNitTestAdapter.

I am using NUnit v.2.6.4 and the NUnitTestAdapter v2.1.1 did the trick.

雨后咖啡店 2024-11-15 13:14:14

删除 _ReSharper 文件夹和 ReSharper CACHE 文件并没有解决我的问题。

我今天遇到了 ReSharper 无法运行单元测试的问题,我通过运行 Clean Solution 然后重建解决方案解决了该问题。

Deleting the _ReSharper folder and the ReSharper CACHE file did not fix the issue for me.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文