简体   繁体   English

尝试运行SpecFlow NUnit测试时出错:“无法访问已处置的对象。 对象名称:“ GherkinLanguageService””

[英]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软件包的列表:

  • Microsoft.Net.Compilers 1.1.0-rc1 Microsoft.Net。编译器1.1.0-rc1
  • NUnit 3.4.0 NUnit 3.4.0
  • NUnitTestAdapter 2.0.0 NUnitTestAdapter 2.0.0
  • Selenium.WebDriver 2.53.0 Selenium.WebDriver 2.53.0
  • SpecFlow 2.1.0 SpecFlow 2.1.0
  • SpecFlow.NUnit 2.1.0 SpecFlow.NUnit 2.1.0
  • SpecFlow.NUnit.Runners 2.1.0 SpecFlow.NUnit.Runners 2.1.0

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.

相关问题 无法访问已处置的对象。 对象名称:'tlsxyz' - Cannot access a disposed object. Object name: 'tlsxyz' 无法访问已处置的对象。 对象名称:“ NumericUpDown” - Cannot access a disposed object. Object name: 'NumericUpDown' AutoMapper IValueResolver:无法访问已处理的对象。 对象名称:'IServiceProvider' - AutoMapper IValueResolver: Cannot access a disposed object. Object name: 'IServiceProvider' ObjectDisposedException:无法访问已处置的对象。 对象名称:“调度程序” - ObjectDisposedException: Cannot access a disposed object. Object name: 'Dispatcher' C#'无法访问已处置的对象。 对象名称:“ SslStream”。 - C# 'Cannot access a disposed object. Object name: 'SslStream'.' HangFire“无法访问已处置的对象。对象名称:'SqlDelegatedTransaction'” - HangFire "Cannot access a disposed object. Object name: 'SqlDelegatedTransaction'" 无法访问已处置的 object。 Object 名称:“图标”,当我所做的只是生成平铺精灵时,MonoGame 中随机出错 - Cannot access a disposed object. Object name: 'Icon', Error randomly in MonoGame when all I'm doing is generating tile sprites 无法访问已处置的 object。 Object 名称:AspNet Core/EF Core 项目中出现“IServiceProvider”错误 - Cannot access a disposed object. Object name: 'IServiceProvider' error in AspNet Core/EF Core project Azure function 启动时出错:无法访问已处置的 object。Object 名称:'IServiceProvider' - Azure function error on startup: Cannot access a disposed object. Object name: 'IServiceProvider' 无法访问已处置的对象。\\ r \\ n对象名称:“ ApplicationUserManager” - Cannot access a disposed object.\r\nObject name: 'ApplicationUserManager'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM