cancel
Showing results for 
Search instead for 
Did you mean: 

Disable specific testcases in a particular Environment

SOLVED
Highlighted
Occasional Contributor

Disable specific testcases in a particular Environment

Can anybody give me an example Setup Script or TearDown Script that can disable specific Testcases in a particular Environment?

 

 For example

 

Environment 1

Environment 2

Environment 3

 

Project

TestSuite

Testcase1

Testcase2

TestSuite

Testcase3

Testcase4

TestSuite

Testcase5

Testcase6

 

 

If Environment = Environment 1,Environment 3

then disable Testcase 1, Testcase 4, Testcase 6

else enable all.

 

 

I can’t see that using tags is environment specific, so I guess a script is the way to go.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Contributor

Here is how you get the environment name and disable a test case. In your teardown script just change setDisabled to false to enable the test case again.

 

//get the environment name
def env =  runner.project.getActiveEnvironment().name

//disable  the test case
def ts = runner.project.getTestSuiteByName("testSuiteName")
def tc = ts.getTestCaseByName("testCaseName")
tc.setDisabled(true)

View solution in original post

3 REPLIES 3
Highlighted
Contributor

Here is how you get the environment name and disable a test case. In your teardown script just change setDisabled to false to enable the test case again.

 

//get the environment name
def env =  runner.project.getActiveEnvironment().name

//disable  the test case
def ts = runner.project.getTestSuiteByName("testSuiteName")
def tc = ts.getTestCaseByName("testCaseName")
tc.setDisabled(true)

View solution in original post

Highlighted
Community Hero

It would easy for the users if you specify if the above script is a setup of test suite or groovy script etc.,


Regards,
Rao.
Highlighted
Occasional Contributor

I've used the below as a TearDown script

 

Thanks!

//get the environment name
def env = runner.project.getActiveEnvironment().name
//def testsuite name
def ts = runner.project.getTestSuiteByName("TestSuite1")

//disable the test suite
if (env == "Environment1"|| env == "Environment3")
{
ts.setDisabled(false)
}
else
{
ts.setDisabled(true)
}

 

New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get a full Raw JMS request

Participate!

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors