solidtoken / SpecFlow.DependencyInjection

SpecFlow plugin that enables to use Microsoft.Extensions.DependencyInjection for resolving test dependencies.
BSD 3-Clause "New" or "Revised" License
35 stars 11 forks source link

Support IAsyncDisposable #48

Closed xsoheilalizadeh closed 9 months ago

xsoheilalizadeh commented 3 years ago

If you register a class that implements IAsyncDisposable to the container it would throw following exception:

TearDown : System.InvalidOperationException : 'IntegrationTests.Order' type only implements IAsyncDisposable. Use DisposeAsync to dispose the container.
--TearDown
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.Dispose()
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.Dispose()
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.Dispose()
   at BoDi.ObjectContainer.Dispose()
   at TechTalk.SpecFlow.Infrastructure.ContextManager.InternalContextManager`1.DisposeInstance()
   at TechTalk.SpecFlow.Infrastructure.ContextManager.InternalContextManager`1.Cleanup()
   at TechTalk.SpecFlow.Infrastructure.ContextManager.CleanupScenarioContext()
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnScenarioEnd()
   at TechTalk.SpecFlow.TestRunner.OnScenarioEnd()
   at GT.Buzzinga.Tests.IntegrationTests.Features.SeedGenerationFeature.TestTearDown()

Package version: 3.7.0 / .NET 5

cc @mbhoek

xsoheilalizadeh commented 3 years ago

I think it's related to BoDi package, if you confirm I can forward it to their repo.

mbhoek commented 3 years ago

@xsoheilalizadeh I think you are correct assuming that it's related to the BoDi package. It does not appear to call DisposeAsync. I did find a PR on SpecFlow trying to solve this (https://github.com/SpecFlowOSS/SpecFlow/pull/1614) but it does not seem ready to merge yet.

mbhoek commented 2 years ago

Update: although the PR mentioned above has been merged for the v4 release, the cause of this issue (BoDi) has not been fixed yet -- there is a PR for it however, so I'll be watching that (https://github.com/SpecFlowOSS/BoDi/pull/51).

mbhoek commented 9 months ago

Closing this issue because the plugin will be donated to Reqnroll.