Exitonfailure and SKIP

Hello everyone,

It is possible to set SKIP for all test cases (in suite tests) after the first test case FAIL ?

With Exitonfailure, robot set FAIL for all test cases, it is not a parameter ?

Thx

Well we have these options:

    --skip tag *          Tests having given tag will be skipped. Tag can be
                          a pattern.
    --skiponfailure tag *  Tests having given tag will be skipped if they fail.
                          Tag can be a pattern 

You can use --skiponfailure but the your test would not be marked Failed, but in the Setup of next tests you could define the tag robot:skip . I actually did some experiments, and failed. So, see below my working example.

*** Keywords ***
Bail Out
    Skip If    "${PREV_TEST_STATUS}" in ["FAIL", "SKIP"]

*** Settings ***
Library           selenium_library

*** Test Cases ***
first test
    No Operation
    Log    ${TEST_DOCUMENTATION}
    Close All Browsers
    [Teardown]    Log    ${TEST_STATUS}

second test
    [Setup]    Bail Out
    No Operation

third test
    [Setup]    Bail Out
    Log To Console    This is test three

Note: Forgot to mention my sponsor :wink: I have used RIDE 2.1.5.2 to create this example :smiley:

1 Like

Thx Hélio, but I need to have my request. It’s important to have the difference between FAIL and SKIP
I tried to do a listener but It doesn’t work !

Hi,

I think Hélio’s idea with setup and teardown is a good approach, I would have done something like this.

Goal is to extract status, and be able to manage it even on first suite test (as ${PREV_TEST_STATUS} doesn’t exist on first test) and you need to manage the status depeding of FAIL/PASS/SKIP:

*** Settings ***
Test Setup          MySetup
Test Teardown       MyTeardown


*** Variables ***
${last_test_runned}        PASS
${last_test_failed}        ${EMPTY}


*** Keywords ***
MySetup
    IF    "${last_test_runned}" == "FAIL"
        Skip    Previous test ${last_test_failed} was failed
    ELSE IF    "${last_test_runned}" == "SKIP" 
        Log   If TEST1 PASS and TEST2 is Skipped, continue on TEST3 Anyway
    END
    # PASS : don't do anything, standard flow

MyTeardown
    IF    "${TEST_STATUS}" == "PASS"
        VAR    ${last_test_runned}    PASS   scope=SUITE
    ELSE IF    "${TEST_STATUS}" == "SKIP" and "${last_test_runned}" == "PASS"
        VAR    ${last_test_runned}    SKIP    scope=SUITE
    ELSE IF    "${TEST_STATUS}" == "FAIL"
        VAR    ${last_test_runned}    FAIL    scope=SUITE
        VAR    ${last_test_failed}    ${TEST_NAME}    scope=SUITE   
    END


*** Test Cases ***
[TEST1] Test1
    Log    TEST1
    Fail

[TEST2] Test2
    Log    TEST2
    Skip    Skipped (remove Fail on TEST1 to try)


[TEST3] Test3
    Log    TEST3

[TEST4] Test4
    Log    TEST4
  • Here if you keep Fail in TEST1, all other tests will be Skipped, with same message due to TEST1:

  • If you remove the Fail line in TEST1 this test PASS, then TEST2 keeps/gets its SKIP status, then TEST3 and TEST4 PASS normally…

  • This manages also the fact that TEST1=PASS, TEST2=SKIP, then TEST3 Fails, so TEST4 is skipped with the message due to TEST3:

Hope this helps.

Regards.

Charlie

1 Like