我想读取每个特性文件并为每个场景创建对象。在读取.feature文件之后。我应该得到像下面这样的东西:
输入
@mytag
Scenario: Add two numbers
Given I have entered 50 into the calculator
And I have entered 70 into the calculator
When I press add
Then the result should be 120 on the screen预期输出
Scenarios -给出特性文件中的所有场景。
Scenario.Steps -给出所有当时给定的场景。
Scenario.Examples -给出了所有的例子。
Scenarios.Tags -所有标签
码
var lines = File.ReadAllText(@"P:\Test.feature");
var scenarios = lines.Split(new string[] { "Scenario: "}, StringSplitOptions.RemoveEmptyEntries);
var scenarioList = new List<Scenario>();
for (int i = 1; i < scenarios.Length; i++)
{
var ind = scenarios[i].IndexOf("\n");
var scenario = new Scenario();
scenario.Name = scenarios[i].Substring(0, ind);
var toInd=scenarios[i].IndexOf("@");
if(toInd>1)
scenario.Steps = scenarios[i].Substring(ind,toInd);
else
scenario.Steps = scenarios[i].Substring(ind);
scenarioList.Add(scenario);
}发布于 2019-01-31 11:38:07
Gherkin Parser应该做你期望的事。你可以在努基特画廊买到
https://stackoverflow.com/questions/54427515
复制相似问题