问题
Spec flow was working fine. I added some more string parameters in one of the Given
statement and suddenly I start getting this error
Class Initialization method AutomatedRediTests.RediFeature.FeatureSetup threw exception. BoDi.ObjectContainerException: BoDi.ObjectContainerException: Primitive types or structs cannot be resolved: System.String.
at BoDi.ObjectContainer.ResolveObject(RegistrationKey keyToResolve, ResolutionList resolutionPath) in W:\SpecFlow\BoDi\BoDi\BoDi.cs:line 772
at BoDi.ObjectContainer.Resolve(Type typeToResolve, ResolutionList resolutionPath, String name) in W:\SpecFlow\BoDi\BoDi\BoDi.cs:line 698
at BoDi.ObjectContainer.Resolve(Type typeToResolve, String name) in W:\SpecFlow\BoDi\BoDi\BoDi.cs:line 680
at TechTalk.SpecFlow.Infrastructure.TestObjectResolver.ResolveBindingInstance(Type bindingType, IObjectContainer container) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestObjectResolver.cs:line 11
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ResolveArgument(IObjectContainer container, IBindingParameter parameter) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 285
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.<>c__DisplayClass42_0.<ResolveArguments>b__0(IBindingParameter p) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 273
at System.Linq.Enumerable.<>c__DisplayClass7_0`3.<CombineSelectors>b__0(TSource x)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ResolveArguments(IHookBinding hookBinding, IObjectContainer currentContainer) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 273
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.InvokeHook(IBindingInvoker invoker, IHookBinding hookBinding, HookType hookType) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 242
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEvents(HookType hookType) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 234
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnTestRunStart() in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 69
at TechTalk.SpecFlow.TestRunner.OnTestRunStart() in D:\a\1\s\TechTalk.SpecFlow\TestRunner.cs:line 29
at TechTalk.SpecFlow.TestRunnerManager.InitializeBindingRegistry(ITestRunner testRunner) in D:\a\1\s\TechTalk.SpecFlow\TestRunnerManager.cs:line 73
at TechTalk.SpecFlow.TestRunnerManager.CreateTestRunner(Int32 threadId) in D:\a\1\s\TechTalk.SpecFlow\TestRunnerManager.cs:line 60
at TechTalk.SpecFlow.TestRunnerManager.GetTestRunnerWithoutExceptionHandling(Int32 threadId) in D:\a\1\s\TechTalk.SpecFlow\TestRunnerManager.cs:line 147
at TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(Int32 threadId) in D:\a\1\s\TechTalk.SpecFlow\TestRunnerManager.cs:line 134
at TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(Assembly testAssembly, Nullable`1 managedThreadId) in D:\a\1\s\TechTalk.SpecFlow\TestRunnerManager.cs:line 224
How do I go about resolving this error? It asks to resolve System.String
EDIT:
looks like in specflow bindings I have a line someMachine abc = SomeControl.BeforeTestRun();
and I needed it to change so it passes a string like someMachine abc = SomeControl.BeforeTestRun("someString");
. When I pass this string , I get this error. No matter if I write the line inside a step definition method or just inside the class.
Is there a way to achieve this?
回答1:
You get this error, if you have a string parameter in the constructor of a class that you get via context injection.
来源:https://stackoverflow.com/questions/57098223/specflow-gives-error-after-adding-more-string-parameters