Skip to content
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

Multiple public constructors with same maximum parameter count are not supported! #2718

Open
ccarmannt opened this issue Aug 4, 2023 · 2 comments
Labels

Comments

@ccarmannt
Copy link

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

@ccarmannt ccarmannt added the Bug label Aug 4, 2023
@clrudolphi
Copy link
Contributor

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

@ccarmannt
Copy link
Author

That's very helpful, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants