我有一些機器人測試用例在目錄中分開。目錄層次是:如何在機器人框架中設置多級測試設置/拆卸
內容的__init__.robot
ParentTestDirectory
|__ ChidTestDirectoryOne
|__ TestOne.robot
|__ ChidTestDirectoryTwo
|__ TestTwo.robot
|__ __init__.robot
:
內容的*** Settings ***
Test Setup LOG TO CONSOLE Test setup from __init__.robot
Test Teardown LOG TO CONSOLE Test teardown from __init__.robot
TestOne.robot
:
TestTwo.robot
*** Settings ***
Test Setup LOG TO CONSOLE Test setup from TestOne.robot
Test Teardown LOG TO CONSOLE Test teardown from TestOne.robot
*** Test Cases ***
Test One
LOG TO CONSOLE This is Test One!
:
*** Settings ***
Test Setup LOG TO CONSOLE Test setup from TestTwo.robot
Test Teardown LOG TO CONSOLE Test teardown from TestTwo.robot
*** Test Cases ***
Test Two
LOG TO CONSOLE This is Test Two!
我有一個使用python編寫的runner,它使用robot runner模塊;這是命令sudo python run.py --testsuit scenarios.ParentTestDirectory
運行測試用例的結果:
==============================================================================
Scenarios
==============================================================================
Scenarios.ParentTestDirectory
==============================================================================
Scenarios.ParentTestDirectory.ChidTestDirectoryOne
==============================================================================
Scenarios.ParentTestDirectory.ChidTestDirectoryOne.TestOne
==============================================================================
Test One Test setup from TestOne.robot
.This is Test One!
.Test teardown from TestOne.robot
Test One | PASS |
------------------------------------------------------------------------------
Scenarios.ParentTestDirectory.ChidTestDirectoryOne.TestOne | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Scenarios.ParentTestDirectory.ChidTestDirectoryOne | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Scenarios.ParentTestDirectory.ChidTestDirectoryTwo
==============================================================================
Scenarios.ParentTestDirectory.ChidTestDirectoryTwo.TestTwo
==============================================================================
Test Two Test setup from TestTwo.robot
.This is Test Two!
.Test teardown from TestTwo.robot
Test Two | PASS |
------------------------------------------------------------------------------
Scenarios.ParentTestDirectory.ChidTestDirectoryTwo.TestTwo | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Scenarios.ParentTestDirectory.ChidTestDirectoryTwo | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Scenarios.ParentTestDirectory | PASS |
2 critical tests, 2 passed, 0 failed
2 tests total, 2 passed, 0 failed
==============================================================================
Scenarios | PASS |
2 critical tests, 2 passed, 0 failed
2 tests total, 2 passed, 0 failed
==============================================================================
正如你看到的,它只是運行最新的測試安裝/拆卸。我希望它能夠從父目錄運行測試設置/拆卸,並且應該在孩子之前執行。換句話說,我希望父設置在每個測試用例分別在自己的設置之前運行。我可以通過機器人框架功能實現嗎?
在所有子測試用例啓動之前,您是否希望父設備只運行一次?如果是這樣,請考慮在'__init __。robot'中使用'Suite Setup'和'Suite Teardown'。還是你想讓父設置在每個測試用例單獨運行之前運行? –
@ A.Kootstra,你的第二個猜測是真實的。我希望父級設置在每個測試用例分別運行之前運行。 –
當第二個選項是你正在尋找的,那麼@Brian Oakley的答案是正確的。 –