2017-01-17 8 views
0

私はXamarinと統合されたSpecFlowを使用しようとしています。テストの間に私は、アプリケーション(*の.apk)をinsltallし、ログインページになって、それをçainchすることができるよしかし、私はエラーを取得:エラーspecflow Xamarinテストの実行時にプリミティブ型または構造体を解決できません

BoDi.ObjectContainerException was unhandled by user code 
HResult=-2146233088 
Message=Primitive types or structs cannot be resolved: Xamarin.UITest.Platform (resolution path: VVM_SpecFlow.LoginApplicationSteps) 
    Source=TechTalk.SpecFlow 
    StackTrace: 
    at BoDi.ObjectContainer.ResolveObject(RegistrationKey keyToResolve, ResolutionList resolutionPath) 
    at BoDi.ObjectContainer.Resolve(Type typeToResolve, ResolutionList resolutionPath, String name) 
    at BoDi.ObjectContainer.<>c__DisplayClass53_0.<ResolveArguments>b__0(ParameterInfo p) 
    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 BoDi.ObjectContainer.ResolveArguments(IEnumerable`1 parameters, RegistrationKey keyToResolve, ResolutionList resolutionPath) 
    at BoDi.ObjectContainer.CreateObject(Type type, ResolutionList resolutionPath, RegistrationKey keyToResolve) 
    at BoDi.ObjectContainer.TypeRegistration.Resolve(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath) 
    at BoDi.ObjectContainer.ResolveObject(RegistrationKey keyToResolve, ResolutionList resolutionPath) 
    at BoDi.ObjectContainer.Resolve(Type typeToResolve, ResolutionList resolutionPath, String name) 
    at BoDi.ObjectContainer.Resolve(Type typeToResolve, String name) 
    at TechTalk.SpecFlow.Infrastructure.BindingInstanceResolver.ResolveBindingInstance(Type bindingType, IObjectContainer scenarioContainer) 
    at lambda_method(Closure , IContextManager) 
    at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration) 
    at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments) 
    at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(StepInstance stepInstance) 
    at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep() 
    at TechTalk.SpecFlow.TestRunner.CollectScenarioErrors() 
    at VVM___SpecFlow.LoginApplicationFeature.ScenarioCleanup() 
    at VVM___SpecFlow.LoginApplicationFeature.LoginWithValidCredentials() in <……..\SpecFlowFeature1.feature:line> 12 
    InnerException: a 

私はspecflowが機能ファイルを読み込みした後、これはhappeingされると信じています。

誰でも教えてください。

+0

コードを表示してください –

+0

Plsは過度の時間をかけてすべての太字コードを正しいフォーマットに変更します。私はあなたを助けてあげましょうこのリンクhttp://stackoverflow.com/help/how-to-ask – Prasad

答えて

2

LoginApplicationStepsには、パラメータXamarin.UITest.Platformを持つコンストラクタがあります。これはあなたを困らせる原始的なタイプです。
SpecFlowには、バインディングクラスを解決するために使用される統合されたDIフレームワークがあります。コンストラクタインジェクションを使用します。あなたのケースでは、それは動作しないプラットフォーム列挙体の登録を探しています。 解決策は、列挙型をクラスにラップしてBeforeScenarioフックに登録することです(リンクされたドキュメントの詳細オプションを参照)。

DI-フレームワーク(SpecFlowで呼ばれるコンテキストインジェクション)へのドキュメントはここにある:http://specflow.org/documentation/Context-Injection/

0

誰もがここでの手順のクラス間のコンテナとしてBodiのを使用している場合は、プリミティブ型に解決するための私の回避策です:

var test = (string)objectContainer.Resolve<object>("testString"); 
関連する問題