SpecFlow
SpecFlow copied to clipboard
Multiple public constructors with same maximum parameter count are not supported!
SpecFlow Version
3.9.74
Which test runner are you using?
NUnit
Test Runner Version Number
3.13.3
.NET Implementation
equal or greater .NET Framework 4.6.1
Project Format of the SpecFlow project
Classic project format using packages.config
.feature.cs files are generated using
SpecFlow.Tools.MsBuild.Generation NuGet package
Test Execution Method
Visual Studio Test Explorer
SpecFlow Section in app.config or content of specflow.json
n/a
Issue Description
Received this error when attempting a test run:
OneTimeSetUp: BoDi.ObjectContainerException : Multiple public constructors with same maximum parameter count are not supported! System.Globalization.CultureInfo (resolution path: TechTalk.SpecFlow.FeatureContext->TechTalk.SpecFlow.FeatureInfo)
Exception doesn't have a stacktrace
Steps to Reproduce
Set up with 2 classes for test hooks.
1:
[BeforeTestRun(Order = 0)]
private static void BeforeTestRun(IObjectContainer container, FeatureContext fContext, ScenarioContext sContext)
{
// stuff here
}
2:
[BeforeTestRun(Order = 0)]
public static void BeforeTestRun(IObjectContainer container, FeatureContext fContext, ScenarioContext sContext)
{
// stuff here
}
If I remove the parameters from at least one of the two methods, this error does not occur.
Link to Repro Project
No response
This error results from attempting to resolve the FeatureContext and/or the ScenarioContext as parameters of the BeforeTestRun hook. Those objects aren't available at that time in the sequence of execution. BoDi (SpecFlow's object container) attempts to resolve those objects using it's default object construction mechanism but it is not sophisticated enough to do that properly.
Instead, use the other hook attributes, such as BeforeFeature or BeforeScenario, that are appropriate to your situation.
HTH
That's very helpful, thanks.