我在VS 2107中的特征文件中的一个步骤中的SpecFlow(2.1.o)中出现以下错误。它应该与SpecFlow框架问题有关吗?
但我在其他功能中没有此错误。他们工作正常。
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 :(得分:0)
错误的原因是[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();
}
。如下。
var _array = [
{name:"sample1" ,date:'08-07-2017'},
{name:"sample2" ,date:'08-07-2017'},
{name:"sample3" ,date:'08-08-2017'},
{name:"sample4" ,date:'08-09-2017'},
{name:"sample5" ,date:'08-09-2017'},
{name:"sample5" ,date:'08-09-2017'}
];
var regrouped = [];
for (var i = 0; i < _array.length; i++) {
var addNew = true;
for (var j = 0; j < regrouped.length; j++) {
if (_array[i].date === regrouped[j][0].date) {
regrouped[j].push(_array[i]);
addNew = false;
}
}
if (addNew) {
regrouped.push([_array[i]]);
}
}
console.log(regrouped);
基本上,每当您尝试通过要素文件插入数据时,您都需要这样做。 之后我遇到了类似的question类型。我可能因为这个问题而错过了这个问题。