You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,12 @@
2
2
3
3
## Improvements:
4
4
5
+
* Microsoft.Extensions.DependencyInjection.ReqnrollPlugin: Added support for configurable service provider lifetimes to control at which scope the services are registered (#998)
6
+
* Options are Global (default, previous behavior), Test Thread, Feature, Scenario
7
+
5
8
## Bug fixes:
6
9
7
-
*Contributors of this release (in alphabetical order):*
10
+
*Contributors of this release (in alphabetical order):*@AidenFuller
### 2. Create static methods somewhere in the Reqnroll project
19
17
20
-
Create a static method in your SpecFlow project that returns a Microsoft.Extensions.DependencyInjection.IServiceCollection and tag it with the [ScenarioDependencies] attribute. Configure your test dependencies for the scenario execution within this method. Step definition classes (i.e. classes with the SpecFlow [Binding] attribute) are automatically added to the service collection.
21
-
22
-
### 3. A typical dependency builder method looks like this:
18
+
## Using the plugin
19
+
20
+
Create a static, parameterless method in your Reqnroll project that returns an instance of `Microsoft.Extensions.DependencyInjection.IServiceCollection` and tag it with the `[ScenarioDependencies]` attribute. Configure your test dependencies for the scenario execution within this method. Step definition classes (i.e. classes with the Reqnroll `[Binding]` attribute) are automatically added to the service collection.
21
+
22
+
A typical dependency builder method looks like this:
23
23
24
24
```csharp
25
25
publicclassSetupTestDependencies
@@ -36,3 +36,23 @@ public class SetupTestDependencies
36
36
}
37
37
}
38
38
```
39
+
40
+
### Configuring the scope and lifetime of the service provider
41
+
42
+
For services registered with a scoped lifetime (as opposed to singleton), it might make sense to have a new scope for each scenario rather than each feature (the default). If this is the case, this can be adjusted with the `ScopeLevel` property on the `[ScenarioDependencies]` attribute. For example
It's also possible to change the lifetime of the entire service provider, rather than just its scope. This is particularly useful when you want a new instance of a singleton service for each feature or each scenario.
0 commit comments