Prevent Tests from being run if Status <> Ready (or any other specific value)
A colleague of mine asked me how we could programmatically prevent a test from being run if its status is different than "Ready" (or any other specific value).
I developed some code and thought I'd share with the forum in case anyone needs to do something similar.
There are two files attached: 1. Common_scripts.txt: this code goes in the Common Scripts module. In case the ActionCanExecute function was already customized, you’ll need to revisit my code to make it work for your situation. If it was not customized, you can just use mine. The code in this file has some global variables and constants you need to keep there, which are used in the TestLab module code. You can customize the values of those constants, which are used for the message boxes displayed to inform the user the execution of the test case instance or test set has stopped. 2. TestLab_module_scripts.txt: this file contains the code for three functions (TestLab_ActionCanExecute, fCheckAllTestsInTestSet, fCheckCurrentTestInTestSet) to be copied in the Test Lab module scripts. Again, if you have a TestLab_ActionCanExecute function already, the code might have to be adjusted. The other two functions are new. You do not need any code for the functions RunTests, RunTestsManually, RunTestSet, RunTests_Sprinter in order for this to work. On the other hand, if you already have code there, you may need to adjust it.
The code is for the Test Lab module and what it does is: - If the selected test set has at least one test case instance in status <> Ready and the “Run Test Set” button is clicked, the message “This Test Set includes at least one Test with status <> Ready which cannot be run.” is displayed to the user and execution is stopped. - If the selected test case instance in a test set has status <> Ready and: -- the “Run” button is clicked, the message “Tests with status <> Ready cannot be run.” is displayed to the user and execution is stopped. -- the “Run Manually” button is clicked, the message “Tests with status <> Ready cannot be run.” is displayed to the user and execution is stopped. -- the “Continue Manual Run” button is clicked, the message “Tests with status <> Ready cannot be run.” is displayed to the user and execution is stopped. - In all other cases (all test case instances with status = Ready) nothing happens, i.e. execution continues.
We don’t use Sprinter on my project, so I could not check the code against it. I'll leave that up to you.
Also, this code works on ALM version 11.
Previous versions of ALM \ QC, or even a different patch, might use different values for ActionName and ActiveModule in the ActionCanExecute events.