Robotframeworkforループは次のテストに進みます

Aug 23 2020

私は以下のコードを持っています:

*** Settings ***
Library     OperatingSystem
Library     Process
Library     String
Test Template    My Run Test
*** Variables ***
@{MyList}=   item  items

*** Test Cases *** 
#name                        type                   profile          file                 test
[XXXXX_1]                   General                test.out         Profile             mode.out 
          [Tags]    TEST-XXXXX   


*** Keywords *** 
My Run Test
    [Documentation]    Run the suite
    [Arguments]       ${type} ${profile}     ${file} ${test}
    : FOR  ${data} IN @{MyList} \ When data is ready \ And tool is ran \ And get was success \ And test suite config is updated \ And testing tool is again run \ Then publish test status data is ready Log to Console "Data is ready" tool is ran Log to Console "tool is ran" Run Keyword And Return Stop Test "This is fun" get was success Log to Console "get was success" test suite config is updated Log to Console "test suite config is updated" testing tool is again run Log to Console "testing tool is again run" publish test status Log to Console "publish test status" Stop Test [Arguments] ${msg}     
    Log To Console    ${msg} Fail ${msg}

それに従って、forループを使用してリスト内のすべてのアイテムに対して一連のキーワードを実行しています。これで、リスト内のアイテムの評価が失敗し、そのテストを失敗としてマークする必要があるが、テストスイートでリスト内の次のアイテムを続行したいという状況が発生しました。

したがって、リストに3つのアイテムがあり、テストケースがリストの2秒のアイテムで失敗した場合、コードはメインのforループに戻り[2番目のアイテムの他のキーワードを続行しない]、3番目のアイテムのテストケースを開始する必要があります。

キーワードFailなどを使用すると、テストスイート全体が停止することに気づきました。これを達成する方法はありますか?

回答

1 BenceKaulics Aug 23 2020 at 18:43

あなたがテストケースにテストテンプレートからforループを抽出して使用する場合は、ループのためにテンプレートを、あなたがお互いから反復が独立して作ることができます。

たとえば、次の変更を加えます。

*** Test Cases *** 
[XXXXX_1]
    FOR  ${data} IN @{MyList} # list item type profile file test ${data}    General    test.out    Profile    mode.out
    END


*** Keywords *** 
My Run Test
    [Documentation]    Run the suite
    [Arguments]       ${data} ${type}     ${profile} ${file}    ${test}
    When data is ready
    And tool is ran
    And get was success 
    And test suite config is updated 
    And testing tool is again run 
    Then publish test status

これは出力になります: