问题描述
使用Specflow 2.3.2和相应的Excel插件以及dotNet Framework(NOT dotNetCore)
string excelPath = @".\CalculatorAdd.feature.xlsx";
ExcelParser excelParser = new ExcelParser( CultureInfo.CurrentCulture,CultureInfo.CurrentCulture );
var specFlowDoc = excelParser.ParseExcel(excelPath);
// all the scenarios are in this specFlowDoc,// just need to export it as feature file,no need to generate code-behind.
// what is next ??
解决方法
FeatureFile是使用
生成的var docFormatter = new SpecFlow.Plus.Excel.SpecFlowPlugin.DocumentFormatter();
string featureFileStr = docFormatter.GetDocumentText(specFlowDoc);
完整代码:
string excelPath = @".\CalculatorAdd.feature.xlsx";
ExcelParser excelParser = new SpecFlow.Plus.Excel.SpecFlowPlugin.ExcelParser( CultureInfo.CurrentCulture,CultureInfo.CurrentCulture );
var specFlowDoc = excelParser.ParseExcel(excelPath);
var docFormatter = new SpecFlow.Plus.Excel.SpecFlowPlugin.DocumentFormatter();
string featureFileStr = docFormatter.GetDocumentText( specFlowDoc );