There can be different solution to achieve this since you have multiple environments i.e., pro software being used.
I would achieve the solution using Test Suite
's Setup Script:
- Create
Test Suite
level custom property. Use the same name as your environment name. For instance, DEV
is the environment defined, use the same as test suite property name and provide the list of values separated by comma as value for that property, say TC1, TC2 etc.,
- Similarly defined other environments and its values as well.
- Copy the below script in
Setup Script
for the test suite and execute the script which enables or disables the test cases according to the environment and property value
Test Suite's Setup Script
/**
* This is soapui's Setup Script
* which enables / disables required
* test cases based on the user list
* for that specific environment
**/
def disableTestCase(testCaze) {
testCaze.disabled = true
}
def enableTestCase(testCaze) {
testCaze.disabled = false
}
def getEnvironmentSpecificList(def testSuite) {
def currentEnv = testSuite.project.activeEnvironment.NAME
def enableList = testSuite.getPropertyValue(currentEnv).split(',').collect { it.trim()}
log.info "List of test for enable: ${enableList}"
enableList
}
def userList = getEnvironmentSpecificList(testSuite)
testSuite.testCaseList.each { kase ->
if (userList.contains(kase.name)) {
enableTestCase(kase)
} else {
disableTestCase(kase)
}
}
Other way to achieve this is using Event
feature of ReadyAPI, you may use TestRunListener.beforeRun()
and filter the test case whether to execute or ignore.
EDIT:
If you are using ReadyAPI
, then you can the new feature called tag
the test cases. A test case can be tagged with multiple values and you can execute tests using specific tags. In this case, you may not needed to have the setup script
as that is for the open source edition. Refer documentation for more details.
This solution is only specific to Pro
software and Open Source edition does have this tag
feature.