如何使用NUnit在VS2010中调试Specflow场景?

发布于 2025-01-05 17:34:11 字数 214 浏览 0 评论 0原文

我已经随 VS2010 安装了 NUnit 2.5.10 和 Specflow 1.8.1。

在VS中右键单击.feature文件,上下文菜单中有一个“调试Specflow Scenarios”项。但我总是得到“找不到匹配的测试运行程序”。在 Tools/Options/Specflow 中,没有 NUnit 的测试运行器选项。

我错过了什么吗?

提前致谢。 :)

I have NUnit 2.5.10 and Specflow 1.8.1 installed with VS2010.

Right click on .feature file in VS, there is an item "Debug Specflow Scenarios" in context menu. But I always get "Could not find matching test runner". In Tools/Options/Specflow, there is no test runner option for NUnit.

Am I missing something?

Thanks in advance. :)

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

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

发布评论

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

评论(4

怼怹恏 2025-01-12 17:34:11

我不知道 NUnit 是否有一个单独的 GUI 来运行测试,因为我使用 MSTests,但这应该是你的做法。

  1. 在您的测试项目中设置一个配置文件,以告诉 Specflow 要使用什么测试框架。
    https://github.com/techtalk/SpecFlow/wiki/Configuration
  2. 工具 >选项>光谱流>测试运行工具是执行测试的工具。事实上,这里没有显示任何内容,似乎没有安装测试运行程序。例如,我有几个,MSTest、Resharper、SpecRun,我通常将其保留为“自动”,然后从我想要使用的测试工具运行测试。我运行了这些安装程序,但应该添加任何 VS 扩展,

您可以尝试使用 VS 运行程序,Test >窗口>测试视图

VS 只会将 Specflow 测试视为 NUnit,因为生成的代码背后只是一个 NUnit 测试(以这种方式配置时)。所以我认为真正的问题是如何在 Visual Studio 中调试 NUnit 测试。快速搜索建议将调试器附加到 NUnit 测试运行程序进程。

I don't know if NUnit has a seperate GUI for running tests as i use MSTests but this should be how u do it.

  1. Setup a config file in your Test Project to tell Specflow what Test framework to use.
    https://github.com/techtalk/SpecFlow/wiki/Configuration
  2. The Tools > Options > Specflow > Test Runner tool is the tool that executes the Tests. The fact that nothing is showing here seems like the test runner is not installed. For example i have several, MSTest, Resharper, SpecRun, i normally leave it on Auto and just run the test from the test tool i want to use. I ran installers for these though which should add any VS extensions

You could try using the VS runner, Test > Windows > Test View

VS will just treat a Specflow test as a NUnit as the generated code behind is just an NUnit test (when configured that way). So i think the real question is how to debug an NUnit test in Visual Studio. A quick search suggested attaching the debugger to the NUnit test runner process.

逆光飞翔i 2025-01-12 17:34:11

和 Ryan 一样,我也没有专门针对 Nunit 的测试运行程序。然而,由于我也在运行 resharper,所以我得到了额外的 resharper 运行程序,这就是 Auto 用来运行它的东西。

你的机器上真的安装了 nUnit 吗?在这种情况下,您可以测试该过程的成功程度,而无需 VS 和 Specflow-addin 的干扰。如果没有,良好的安装可能会为您提供所需的跑步者。

或者,我使用 nCrunch 自动运行所有测试。过去几个月我一直在多个解决方案上运行 nunit/specflow ,没有出现任何问题。那么根本不需要右键单击。 :-)

Like Ryan I also have no test runner specifically for Nunit. However since I'm also running resharper I get additional resharper runners, and that is what Auto uses to run it.

Have you actually got nUnit installed on your machine? In which case you can test how successful the process is without VS and Specflow-addin getting in the way. If not, well installing may give you the runner you need.

Alternatively, I use nCrunch to automatically run all my tests. I've had it running nunit/specflow for the last few months on multiple solutions with no issues. No need to right click at all then. :-)

谁的年少不轻狂 2025-01-12 17:34:11

SpecFlow 本身不提供测试运行程序,如果您想右键单击 .feature 并运行它,则必须重新配置 SpecFlow 以使用 MSTest,后者应使用内置 VS 运行程序。

如果您想使用 NUnit,则需要额外的工具。我推荐 Resharper,但它不是免费的。查看这篇文章 了解从 VS 运行 NUnit 测试的更多选项。

SpecFlow itself does not provide a test runner and if you want to right click on the .feature and run it, you'll have to re-configure SpecFlow to use MSTest, which should use built-in VS runner.

If you want to use NUnit, then additional tools are required. I would recommend Resharper, but it's not free. Check out this article for more options to run NUnit tests from VS.

纵性 2025-01-12 17:34:11

再会。要调试,我执行以下操作:

  1. 在您感兴趣的场景行上放置一个断点
  2. 确保您正在运行 NUnit
  3. 附加 NUnit 进程
    • 转到工具
    • 选择附加进程
    • 在可用进程中选择 NUnit agent.exe
    • 点击“附加”
  4. 运行要在 NUnit 中调试的测试

希望有帮助

Good day. To debug i do the following :

  1. Put a break point on the scenario line that you are interested in
  2. Make sure that you have NUnit running
  3. Attach the NUnit process
    • Go to tools
    • Select attach process
    • In the available processes select NUnit agent.exe
    • Click attach
  4. Run the test you want to debug in NUnit

Hope that helps

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