2015-03-31 81 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

相關問題