Forum Discussion

mrdwprice's avatar
mrdwprice
Contributor
5 years ago
Solved

Disabling specific test case using project Setup Script

I have the below script to disable a TestSuite using the project Setup Script.

 

//get the environment name
def env =  runner.project.getActiveEnvironment().name
//def testsuite name
def ts = runner.project.getTestSuiteByName("Testsuite1")
//disable the test suite
ts.setDisabled(true)
//disable the test suite based on environment
if (env == "Environment 1"|| 
env == "Environment 5")
{
ts.setDisabled(false)
}
else
{
ts.setDisabled(true)
}

How can a make a similar script, again from project Setup Script, but to disable specific test cases instead?

 

Thanks

David

 

  • The WsdlTestCase class has the setDisabled method so from a Project start up script which provides you with the variable "project" you can use the following:

     

    project.getTestSuiteByName("TestSuite 1").getTestCaseByName("TestCase 2").setDisabled(true)

     

1 Reply

  • Radford's avatar
    Radford
    Super Contributor

    The WsdlTestCase class has the setDisabled method so from a Project start up script which provides you with the variable "project" you can use the following:

     

    project.getTestSuiteByName("TestSuite 1").getTestCaseByName("TestCase 2").setDisabled(true)