[Return] does not stop the test, it simply exits the keyword in a PASS state, so naturally Robot Frameworks says, that keyword passed so continue to the next one.
If logic test looked like this:
LogicTest
IF 1==1
[Return] or do not execute further keywords. stop execution and generate report
END
Log After If Log Me
Then the line Log After If Log Me would not get executed.
You probably want to look at using Fail, Pass Execution, or similar keywords inside your IF statement.
The [Return] setting defines what the keyword should return after it has been executed
I guess meaning it doesn’t actually return from the keyword at that point (I’ve never actually used it this way). You should probably use this (post RF v5.0) syntax instead.
LogicTest
IF 1==1
RETURN or do not execute further keywords. stop execution and generate report
END
Log After If Log Me
But for your original issue you really need to look into using the Fail and Pass Execution keywords, as they are the one’s that should prevent the execution of SubmitTest
You could do something like this, the only problem is all your skipped tests will be marked as PASS not SKIP, but if that’s ok this might be a solution for you?
skippy.robot
*** Settings ***
Documentation An example of skipping the rest of the tests without failing when one meets a certain criteria
*** Variables ***
${Skip} False
*** Test Cases ***
Always Run
Log This test always runs
Log All the way to the end
Do Logic Test
LogicTest
Skip Me
Pass Execution If ${Skip} Test Case Skipped
Log Never actually gets here
Log or here here
Skip Me As Well
Pass Execution If ${Skip} Test Case Skipped
Log Never actually gets here
Log or here here
Skip Me Too
Pass Execution If ${Skip} Test Case Skipped
Log Never actually gets here
Log or here here
*** Keywords ***
LogicTest
IF 1==1
Set Suite Variable ${Skip} True
RETURN or do not execute further keywords. stop execution and generate report
END
Log After IF Log Me
@damies13
Logic looks good but We will have to add this line -Pass Execution If ${Skip} Test Case Skipped in all the subsequest keyword and test cases to check whether ${Skip} is set to true or not. I was thinking little out of box but that’s ok
Any other way do we have?
Instead of impacting test status and we should not need to add check for ${Skip} ==True
I don’t know of any other way to do what you were asking for, Pekka would know better than me, and the solution I offered is, I agree, a bit of a hack, but it seems as best I can tell the Fatal Error keyword is the only alternative, but that had the test Fail which you didn’t want.
Is it possible to create a python library with a keyword that passes the current test and stops further execution? Maybe. I don’t know enough about robot framework (especially the internals) to say.
What your wanting to do seems to be a bit of an unusual scenario, but I guess if it’s important enough to you raise a feature request, the worst that could happen is it gets rejected and your in the same place as now.
But is is overriding original status of test. As I have to perform some activity based on ${TEST_STATUS } in Test Cleanup, If I marked that as SKIP and if all of the keyword already passed/failed then it is marking overall status as SKIP.
“As I have to perform some activity based on ${TEST_STATUS } in Test Cleanup, If I marked that as SKIP and if all of the keywords already passed/failed then it is marking overall status as SKIP.”
The Skip and Skip If doesn’t override the original status only that one test or many for which you choose to skip would show as SKIP as they are being skipped from running if you choose to skip it due to the outcome of another test, while all other tests would show PASS or FAIL? so in your post example: “SubmitTest” would hold a status of SKIP while all others would be PASS or FAIL.
Unless you’re speaking about the individual keywords in an individual test case then they would show their outcome in the generated report anyways.
I’d assume in your clean up as you speak about doing action on ${TEST_STATUS } you’d be able to handle/ignore skipped tests as you can access the test status from there if you were not to use the keyword Pass Execution and were to actually show the SKIP status for what it is actually doing.
If any of the keyword status is failed then it should not mark overall ${TEST_STATUS} to pass. Since I have used pass execution it is marking overall status to PASS. Because in Test TearDown based on status , I have to perform some other task
Hence I want to stop execution without impacting original ${TEST_STATUS}