2015-03-31 65 views
1

如何使用定制标签来选择场景运行?在行为框架中使用定制标签运行场景

对于Eaxmple,下面是功能文件

Feature:my example feature 

@Test_Name:sample @abc:1234 @sd:567 

Scenario: Example scenario 
Given my Name is sample 
When my Name is whensample 
Then my Name is endsample 

我有多个特征文件和每一个特征文件有很多scenarios.scenario标签类似于上面提到的方式。 我试图让运行方案

behave -t Test_Name --> to run all files 
    behave -t abcd --> run specific scenario 
    behave -t 1234 --> run specific scenario 

请建议,如果有什么办法做到这一点。

回答

1

添加标签到像@ testtag1,@ testtag2方案如下所示


Feature: showing off behave 
    @testtag1 
    Scenario: run a simple test 
    Given we have behave installed 
     when we implement a test 
     then behave will test it for us! 

    @testtag2 
    Scenario: run a simple test2 
    Given we have behave installed 
     when we implement a test 
     then behave will test it for us! 

@testtag1 
    Scenario: run a simple test3 
    Given we have behave installed 
     when we implement a test 
     then behave will test it for us! 

执行命令

behave --tags=testtag1

测试情景其标记是testtag1

相关问题