Hello Everyone,
I’m wanted to know if there’s a solution to execute test cases without Prefix. There are specific test cases for which I need to run a cutom defined keyword at the end in the [Teardown] method after the execution of those test cases.
I thought of using [Tags] but it wouldn’t be feasible in my cases as the test cases are generated through a 3rd party tool. Also, every time the test cases are generated through that 3rd party tool the order of test cases gets changed in the test file.
My test case file looks like this:
*** Test Cases ***
TC01_Order_Tests
[Documentation] Order Tests
Log This is Test 1
[Teardown] Final Test
TC02_Register_Tests
[Documentation] Register Tests
Log This is Test 2
[Teardown] Final Test
... and so on
I thought of removing the prefix and then use it in the [Teardown] Final Test method. Below is the code that I’ve written:
*** Keywords ***
Remove Prefix from Test Case Names
${test_case_names} Create List TC017_Login_Tests TC018_Search_Tests TC018_Purchase_Tests
${updated_test_case_names} Create List
FOR ${test_case_name} IN @{test_case_names}
${suffix} Get Substring ${test_case_name} 6
Append To List ${updated_test_case_names} ${suffix}
END
Log To Console ${updated_test_case_names}
Set Global Variable ${updated_test_case_names}
Final Test
${status} Run Keyword And Return Status Page Should Contain Error Message
Run Keyword If ${status}==${true} Run Keywords Remove Prefix from Test Case Names AND Run Keyword If ${TEST NAME} in ${updated_test_case_names} My Custom Keyword
Close Browser
I added those set of test cases in a list and then remove the prefix but it didn’t got executed.
When I use the below code written code it works like charm:
Run Keyword If ${TEST NAME} in ['TC017_Login_Tests', 'TC018_Search_Tests', 'TC018_Purchase_Tests'] My Custom Keyword
I even tried using [Documentation] in the same way as the above code but it also didn’t got executed.
Can anyone help me out here. Thanks in advance.