获取场景大纲示例

问题描述 投票:0回答:2

我目前想要返回场景大纲示例的行并获取行的大小,但是我无法执行此操作,因为当 SpecRun 读取功能文件时,它会自动将场景大纲示例转换为自定义报告的单独场景我们想要创建需要这些信息的内容。

ScenarioContext.Current.ScenarioInfo 没有给我这种能力。

当在 JAVA 中遇到同样的问题时,我们将 gherkin.formatter 实现到自定义类中,并在 RunCukesTest 类中使用 plugins = {"my.package.customreport"} 调用它

但是我不确定导入 gherkin.dll 后如何在 .Net SpecRun 中完成相同的操作。

任何人都可以阐明这一点或提供替代解决方案吗?

谢谢!

c# .net cucumber specflow specrun
2个回答
1
投票

正如您所写:我需要它适用于所有步骤,但这也没有给我示例数量和迭代数量。

场景大纲:场景大纲示例

Given I have RestAPI '<iterationNumber>'

When I read '<iterationNumber>' and '<api_key>' 

Then the '<iterationNumber>' and results table
| links list |
| aaa        |
| bbb        |

Examples:
| iterationNumber | api_key                      |
| 0               | @@app.config=api_key_full    |
| 1               | @@app.config=api_key_limited |

调试这个

    [Given(@"I have RestAPI '(.*)'")]
    public void GivenIHaveRestAPI(int iterationNumber)
    {
        Console.WriteLine(iterationNumber);
    }

    [When(@"I read '(.*)' and '(.*)'")]
    public void WhenIReadAnd(int iterationNumber, string p1)
    {

        Console.WriteLine(iterationNumber);
    }

    [Then(@"the '(.*)' and results table")]
    public void ThenTheAndResultsTable(int iterationNumber, Table table)
    {
        Console.WriteLine(iterationNumber);
    } 

0
投票

但是我的示例中有两个以上的字段。那么,我该怎么做呢

例如

示例:

|菲尔德1|菲尔德2|菲尔德3|菲尔德4|菲尔德5|

|值1|值2|值3|值4|值5|

© www.soinside.com 2019 - 2024. All rights reserved.