如何使用NUnit 3.11配置Specflow 3.0.199? [英] How to Configure Specflow 3.0.199 with NUnit 3.11?

查看:90
本文介绍了如何使用NUnit 3.11配置Specflow 3.0.199?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前已经做过几次,但是今天不起作用.我想念什么吗?

I have done this a couple of times before, but it's not working today. Am I missing something?

我想使用NUnit从脚本配置Specflow并在Visual Studio中执行. 我看过很多教程,但它们对我不起作用:P.我正在尝试使用最新版本.

I want to configure Specflow from the scract, using NUnit and to execute inside Visual Studio. I've seen many tutorials but they are not working to me :P. I'm trying to use the latest versions.

这些是我在Visual Studio 2017上正在执行的步骤:

These are the steps I'm doing on Visual Studio 2017:

  • 创建测试项目(.NET Framework)
  • 为Visual Studio安装Specflow插件(工具>扩展和更新)
  • 从nuget软件包中删除MSTests的引用.
  • 安装SpecFlow 3.0.199
  • 安装NUnit 3.11
  • 安装SpecRun.Runner 3.0.284

创建默认功能文件并生成其步骤后,在编译解决方案时,我在CalculatorFeature.feature.cs(生成的文件)上收到此错误:

After creating a default feature file and generate its steps, when I compile the solution I get this error on CalculatorFeature.feature.cs (the generated file):

就像那些配置不兼容.这是怎么回事? 如果您还有其他分步列表,请让我知道如何使用NUnit配置Specflow以在Visual Studio 2017上运行.

It's like those configurations are not compatible. What's going on? If you have another step by step list, let me know how to configure Specflow with NUnit to run on Visual Studio 2017, please.

推荐答案

对于SpecFlow 3,您必须使用MSBuild生成器.

For SpecFlow 3 you have to use the MSBuild generation.

为此,请执行以下两个步骤:

To this, follow these two steps:

  1. 将与SpecFlow相同版本的NuGet包SpecFlow.Tools.MsBuild.Generation添加到您的项目中
  2. 从功能文件中删除所有SpecFlowSingleFileGenerator自定义工具条目.

来自 https://specflow.org/2019/generating -code-behind-files-using-msbuild/

背景情况:

有时,VS扩展在查找使用的SpecFlow版本时会遇到问题.在这种情况下,它会退回到该扩展附带的SpecFlow版本(确实很旧).此版本正在生成现在不存在NUnit属性的代码.

The VS Extension has sometimes problems to find the used SpecFlow version. In that case, it falls back to the SpecFlow version shipped with the extension (which is really old). This version is generating code with now not existing NUnit attributes.

这篇关于如何使用NUnit 3.11配置Specflow 3.0.199?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆