规范流程运行正常。我在Given
语句之一中添加了更多字符串参数,突然我开始收到此错误
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
如何解决该错误?它要求解决System.String
编辑:
看起来像在specflow绑定中,我有一行someMachine abc = SomeControl.BeforeTestRun();
,我需要对其进行更改,以便它传递类似someMachine abc = SomeControl.BeforeTestRun("someString");
的字符串。当我传递此字符串时,会出现此错误。无论是在步骤定义方法中还是在类中编写该行。
有没有办法做到这一点?
答案 0 :(得分:1)
如果通过上下文注入获得的类的构造函数中有字符串参数,则会出现此错误。