Robotframework for loop kontynuuje następny test

Aug 23 2020

Mam poniżej kod:

*** 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}

W związku z tym uruchamiam zestaw słów kluczowych dla wszystkich pozycji na liście za pomocą pętli for. Teraz mam sytuację, w której ocena pozycji na liście nie powiodła się i muszę oznaczyć ten test jako niepowodzenie, ale chcę, aby zestaw testów był kontynuowany z następnymi pozycjami na liście.

Dlatego załóżmy, że na liście są 3 pozycje, a przypadek testowy kończy się niepowodzeniem przez 2 sekundy na liście, a następnie kod powinien wrócić do pętli głównej for [nie kontynuować z innym słowem kluczowym dla drugiej pozycji] i uruchomić przypadek testowy dla trzeciej pozycji.

Zauważyłem, że użycie słowa kluczowego Fail i innych zatrzymuje cały zestaw testów. Czy jest na to sposób?

Odpowiedzi

1 BenceKaulics Aug 23 2020 at 18:43

Jeśli wyodrębnisz pętlę for z szablonu testowego do przypadku testowego i użyjesz szablonów z pętlami for , możesz uniezależnić iteracje od siebie.

Na przykład z następującymi modyfikacjami:

*** 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

Byłby to wynik: