I haven’t found a sophisticated solution to SKIP in Robot Framework (compare this issue).
So you have to implement such a mechanism on your own.
There are two parts:
1.) the independent testcase (or testsuite)
2.) the dependent testcase (or testsuite)
1.) The independent testcase
Execute in [Teardown] only one keyword, because Robot Framework restricts more then one (the same applies to [Setup]).
Because IMHO the SKIP mechanism belongs to the testcases, I wouldn’t put the keyword definition in a ressource file, but at the end of the test case file.
Because you typically will take a screenshot in the testcase teardown, the file would look like this:
*** Variables ***
${SkipDependenciesOfTestcase1} False # this declaration avoids "Non-existing variable '${SkipDependenciesOfTestcase1}'"-Error which happens non-deterministically (=sometimes).
*** Test Cases ***
Testcase 1
Testing Keyword 1
Testing Keyword 2
(...)
[Teardown] Teardown Testcase 1
(...)
*** Keywords ***
Teardown Testcase 1
Capture Page Screenshot Teardown Testcase 1.png
Run Keyword If Test Failed Set Global Variable ${SkipDependenciesOfTestcase1} True
2.) The (appropriate) dependent testcase
You have to put the second part of the SKIP mechanism into the [Setup] of the dependent testcase:
*** Test Cases ***
(...)
Testcase 2
[Setup] Setup Testcase 2
Testing Keyword 3
Testing Keyword 4
(...)
*** Keywords ***
(...)
Setup Testcase 2
Run Keyword If '${SkipDependenciesOfTestcase1}'=='True' Fail SKIPPED due to failure of testcase 1.
Some testautomaters prefer to PASS a SKIPed testcase: Pass Execution Keyword
Tip: You can test your implementation of skip mechanism with an empty page, because then the independent testcase fails certainly and quick.
For more information on Robot Framework read: https://it-kosmopolit.de/strategic-link-collection-of-robot-framework/
Run Keyword If Test Failed Set Global Variable ${SkipDependenciesOfTestcase1} ${ True} ELSE Set Global Variable ${SkipDependenciesOfTestcase1} ${ False}
this should do the trick instead of static declaration of variable.