2017-08-06 100 views
0

我在功能文件的其中一個步驟中得到了低於VS 2107中的speckFlow(2.1.o)中的錯誤。它應該與SpecFlow框架問題有關嗎?SpecFlow功能文件錯誤 - 對象必須實現IConvertible

但是我在其他功能中沒有這個錯誤。他們工作正常。

enter image description here

錯誤XXXXfeature.cs文件:

Test method ABC.Api.Bdd.Tests.Features.V2.InstantTrackerFeature.InstantTrackerReturnsA500ErrorResponseWhenErrorScenariosOccur threw exception: 
System.InvalidCastException: Object must implement IConvertible. 
    at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) 
    at TechTalk.SpecFlow.Bindings.StepArgumentTypeConverter.ConvertSimple(Type typeToConvertTo, Object value, CultureInfo cultureInfo) 
    at TechTalk.SpecFlow.Bindings.StepArgumentTypeConverter.ConvertSimple(IBindingType typeToConvertTo, Object value, CultureInfo cultureInfo) 
    at TechTalk.SpecFlow.Bindings.StepArgumentTypeConverter.Convert(Object value, IBindingType typeToConvertTo, CultureInfo cultureInfo) 
    at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ConvertArg(Object value, IBindingType typeToConvertTo) 
    at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.<>c__DisplayClass38_0.<GetExecuteArguments>b__0(Object arg, Int32 argIndex) 
    at System.Linq.Enumerable.<SelectIterator>d__5`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.GetExecuteArguments(BindingMatch match) 
    at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(StepInstance stepInstance) 
    at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep() 
    at TechTalk.SpecFlow.TestRunner.CollectScenarioErrors() 
    at ABC.Api.Bdd.Tests.Features.V2.InstantTrackerFeature.ScenarioCleanup() 
    at ABC.Api.Bdd.Tests.Features.V2.InstantTrackerFeature.InstantTrackerReturnsA500ErrorResponseWhenErrorScenariosOccur() in C:\ABC.API\ABC.Api.Bdd.Tests\features\v2\InstantTracker.feature:line 36 
+0

經過進一步調查,似乎整個功能文件的問題。由於這種相同的錯誤,沒有任何一種方案正在工作。重新生成功能文件,但沒有運氣。 – SMPH

回答

0

的原因錯誤失蹤StepArgumentTransformation。如下。

[StepArgumentTransformation] 
     public IList<MovesStaging> TransformMovesStaging(Table identifiers) 
     { 
      return identifiers.Rows.Select(row => new MovesStaging 
      { 
       PartitionKey = ParseTableRowFieldAsString(row, "PartitionKey"), 
       RowKey = ParseTableRowFieldAsString(row, "RowKey"), 
       Timestamp = ParseTableRowFieldAsTimeStampUtc(row, "Timestamp"), 
       Status = ParseTableRowFieldAsString(row, "Status"), 
       ExpiryDate = ParseTableRowFieldAsDateTimeUtc(row, "ExpiryDate") 
      }).ToList(); 
     } 

基本上,每當你試圖通過功能文件插入數據,你需要有這個。 之後我遇到了類似的question。我錯過了這個問題,也許是由於這個問題。

+1

當需要綁定時需要這個,它需要一個IList 參數而不是一個Table參數。 –

+1

也看看TechTalk.SpecFlow.Assist命名空間:http://specflow.org/documentation/SpecFlow-Assist-Helpers/有處理表的助手。 –

相關問題