在功能级别Specflow中设置环境

时间:2018-01-17 10:27:08

标签: specflow

我有一个包含3个场景的功能文件,我想知道Specflow是否具有以下实现:我可以在功能级别设置环境吗?我想在测试开始时指定环境,以便场景在顶部指定的环境中运行。

Feature: SpecFlowFeature
    In order to avoid silly mistakes
    As a math idiot
    I want to be told the sum of two numbers on DEV environment <= Can I do this? Can DEV be a parameter?

@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

如果我不能这样做,你能为我的情况提供解决方案吗?先谢谢你。

1 个答案:

答案 0 :(得分:0)

我的建议是,使用BeforeFeature钩子。这样,您就可以根据自己运行的功能定义环境。

您可以在此处查看文档。它会解决你的问题。 https://github.com/techtalk/SpecFlow/wiki/Hooks