-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autofac without BeforeTestRun
hook does not run GlobalDependencies
#127
Comments
Okay, so, digging a bit deeper still - it's because we can't access things from the global context inside of our step definitions. In my use-case, have you got any advice on how to achieve this? |
@michielboekhoff You can let the |
@michielboekhoff I have also run into a similar issue while trying to fix #56, but not exactly yours and I could not reproduce your case. What I have found was that before processing the |
@michielboekhoff Ignore my last comment. I was able to reproduce the problem. It seems that any hook fixes the problem, not only |
OK. I understand it now why it was wrong. Basically the |
…ons-dependencyinjection-plugin * origin/main: (21 commits) Fix #56 autofac ambiguous stepdef and hook required #127 issue (#139) Reduce target framework of Reqnroll to netstandard2.0 (#130) Fix StackOverflowException when using [StepArgumentTransformation] with same input and output type (#136) MsTest: Replace DelayedFixtureTearDown special case with ClassCleanupBehavior.EndOfClass (#128) Temporarily disabled tests until #132 is resolved Add NUnit & xUnit core tests to portability suite Capture ExecutionContext after every binding invoke (#126) small improvement in CodeDomHelper to be able to chain async calls fix method name sources in UnitTestFeatureGenerator External data plugin, support for JSON files (#118) UnitTests: Check if SDK version is installed and if not ignore the test (#109) Fix 111 ignore attr not inherited from rule (#113) Update README.md (#110) Fix 81 - modified CucumberExpressionParameterTypeRegistry to handle multiple custom types used as cucumber expressions when those types share the same short name. (#104) Update index.md Simplify test project targets (#105) Make SystemTests temp folder configurable and use NUGET_PACKAGES env var to override global NuGet folder Fleshing out Generation System Tests (2) (#99) Fix for 81 - Cucumber Expression using Enums errors when two enums exist with the same short name (#100) Include BoDi to Reqnroll package (#91) (#95) ... # Conflicts: # Reqnroll.sln # Tests/Reqnroll.PluginTests/Reqnroll.PluginTests.csproj
…hread-container * origin/main: Extract cucumber expression detection heuristic to an interface fix test artifact folder calculation Restructure solution folders (#141) cleanup CHANGELOG.md ignore generated file remove generated file bump version Add Microsoft.Extensions.DependencyInjection integration plugin (#94) Fix #56 autofac ambiguous stepdef and hook required #127 issue (#139) Reduce target framework of Reqnroll to netstandard2.0 (#130) Fix StackOverflowException when using [StepArgumentTransformation] with same input and output type (#136) # Conflicts: # CHANGELOG.md
Reqnroll Version
1.0.1
Which test runner are you using?
xUnit
Test Runner Version Number
2.7.0
.NET Implementation
.NET 8.0
Test Execution Method
Other – PLEASE SPECIFY
Content of reqnroll.json configuration file
Issue Description
Hey there! First of all, thanks so much for this project. I'm really happy that it's been picked up, and I'm really happy to see how active this repo has been recently.
Since I've started using the Autofac plugin, I've been seeing mildly strange behaviour with the
[GlobalDependencies]
attribute. I've been writing integration tests using Testcontainers, and I want to set up a single container to share across all features. To this end, I've got a fairly complexGlobalDependencies
class:GlobalDependencies.cs
ScenarioDependencies.cs
The code annotated with
GlobalDependencies
runs only if I have a[BeforeTestRun]
hook.After some investigation, I believe it's because of an issue in the
BindingRegistryExtensions
class. It appears that, at the time of the global container registration, theIBindingRegistry
is not ready yet (understandable, as it can't map the step definitions). Without any[BeforeTestRun]
hooks,GetBindingTypes
returns an emptyIEnumerable
andGetBindingAssemblies
returns an emptyIEnumerable
too. This ultimately means thatGetMethod
inContainerBuilderFinder.cs
returnsnull
which causes this condition to trigger:(e.g., the code thinks there is no
[GlobalDependencies]
-annotated method!)Steps to Reproduce
Create a project which uses
[GlobalDependencies]
, uses the Autofac plugin but has no hooks. Add an empty[BeforeTestRun]
hook like this:to make the issue disappear.
I can also set up a repro project if desired!
Link to Repro Project
No response
The text was updated successfully, but these errors were encountered: