[英]Error when attempting to run SpecFlow NUnit test: “Cannot access a disposed object. Object name: 'GherkinLanguageService'”
I am setting up NUnit C# tests using SpecFlow, but the ones declared in my SpecFlowFeature don't seem to be picked up by the Text Explorer. 我正在使用SpecFlow设置NUnit C#测试,但我的SpecFlowFeature中声明的测试似乎没有被文本浏览器接受。 When trying to manually run the scenario (by right-clicking on them) I get the following error:
尝试手动运行场景时(通过右键单击它们),出现以下错误:
"Cannot access a disposed object. Object name: 'GherkinLanguageService'"
...which doesn't ring any bell at all. ...这根本不打铃。 Anyone has any suggestion on how to allow them to run?
任何人都对如何允许它们运行有任何建议?
The Feature Code is as follows: 功能代码如下:
Feature: SpecFlowFeature
As a user
I would like to go to the what we do page
In order to see what we do information
@UI
Scenario: What we do Browsing
Given I have the home page open
When I select what we do from the menu
Then I see the what we do information
@UI
Scenario: Add an Asset to a Client page
Given I have the home page open
When I go to a client page
And I click the Add Download button
And I fill in the form
And I choose a file to upload
And I submit the form
Then I see the newly-submitted file
And the Steps definitions are all automatically generated. 并且步骤定义都是自动生成的。
EDIT: List of installed NuGet packages in my Test Project: 编辑:我的测试项目中已安装的NuGet软件包的列表:
Have a look at the code in this repo https://github.com/SabotageAndi/SpecFlow.Example.AllTestRunners and compare it with your project. 看看此仓库https://github.com/SabotageAndi/SpecFlow.Example.AllTestRunners中的代码,并将其与您的项目进行比较。
It contains a SpecFlow project for NUnit 2 and NUnit 3.2.1. 它包含用于NUnit 2和NUnit 3.2.1的SpecFlow项目。
There the NUnit Tests are visible in the Visual Studio Test Explorer. 在Visual Studio测试资源管理器中可以看到NUnit测试。
First I would try a downgrade to 3.2.1 of NUnit. 首先,我尝试将NUnit降级到3.2.1。 Perhaps there is some problem in connection with the NUnitTestAdapter.
NUnitTestAdapter可能存在一些问题。
The problem was a subtle dependency issue. 问题是一个细微的依赖问题。 The previous version used NUnit 2.x, while my current version uses NUnit 3.x;
以前的版本使用NUnit 2.x,而我的当前版本使用NUnit3.x。 now in order to use NUnit I need a NuGet package called "NUnit Test Adapter", but upgrading it is not enough: apparently for NUnit 3+ there is a different package called "NUnit 3 Test Adapter" which is not just an upgraded version of the previous one - but a different one altogether.
现在为了使用NUnit我需要一个NuGet包叫做“NUnit测试适配器”,但升级是不够的:显然是NUnit的3+有不同的包叫做“NUnit的3测试适配器”,这不仅是一个升级版前一个-但完全不同。
Installing NUnit 3 Test Adapter solved my problem. 安装NUnit 3测试适配器解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.