Enabling and disabling test cases from test suite
I have excel with all test cases for the suite.My req is to disable all testcases from test suite start up script when the test begins.Based on if the test case is set for run (one excel cloumn would read "yes" for run),i would be enabling the tets cases that are required to be run.
So,I am trying to Enable and Disable test case from Test Suite level.
From Test suite level start up script,
i am trying as below
isDisabled=runner.testSuite.getTestCaseByName(strLabel).isDisabled() if (isDisabled!=true) {runner.testSuite.getTestCaseByName(TestCaseLabel).disabled=true}
throws error ---cannot invoke method on null object.
Scenario 2:
Trying to enable all disabled test cases from start up script.
runner.testSuite.getTestCaseByName(strExcelTestCase).disabled=false
again same error.Please help.This is stopping the framework development
If you want to just enable all the cases :
testSuite.testCaseList.each { it.disabled = false }
To disable:
testSuite.testCaseList.each { it.disabled = true }
To enable a test case by name:
testSuite.testCases['TestCase 1'].disabled = false //you may change test case name.
To disable:
testSuite.testCases['TestCase 1'].disabled = true //you may change test case name.
Does it help?
EDIT: Was little confusing, after looking into details, then come to know the following:
Are you using Test Case label in your script instead of Test Case name? There is a difference.
log.info testSuite.testCases['TestCase 1'].name log.info testSuite.testCases['TestCase 1'].label
Output:
Wed Dec 09 07:15:07 IST 2015:INFO:TestCase 1 Wed Dec 09 07:15:07 IST 2015:INFO:TestCase 1 (disabled)