Disable specific testcases in a particular Environment
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2019
12:08 AM
03-27-2019
12:08 AM
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!
Solved! Go to Solution.
Labels:
- Labels:
-
Data-Driven Testing
-
Scripting
3 REPLIES 3
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2019
07:34 AM
03-27-2019
07:34 AM
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)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2019
06:47 PM
03-27-2019
06:47 PM
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.
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2019
12:12 AM
03-28-2019
12:12 AM
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) }
