Forum Discussion

PrakashKannan's avatar
PrakashKannan
Contributor
7 years ago
Solved

Disabling test case in set up script at project level is not working

I want to disable few test cases whose name matches something. I used below script. But it does not disable the test cases

 

runner.project.testSuiteList.each{
def tcList=it.getTestCaseList()
tcList.each{
if(it.toString().contains("_xsi"))
it.disabled=true
}
}

  • groovyguy's avatar
    groovyguy
    7 years ago

    Try this:

     

    testSuite.project.getTestSuiteList().each
    {
    	def tcList=it.getTestCaseList()
    	tcList.each
    	{
    		log.info(it.getName());
    		if(it.getName().contains("B"))
    		{
    			it.disabled=true;
    		}
    	}
    }

9 Replies

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    I took your script and cleaned it up a bit. I had to adjust it to use the context variable, and you have to test the name of the test case object and not the object itself. Otherwise you were close.

     

    context.testCase.testSuite.project.getTestSuiteList().each
    {
    	def tcList=it.getTestCaseList()
    	tcList.each
    	{
    		log.info(it.getName());
    		if(it.getName().contains("B"))
    		{
    			it.disabled=true;
    		}
    	}
    }
    • PrakashKannan's avatar
      PrakashKannan
      Contributor

      Thanks but when I run it says 'can not get property 'testSuite' on null object.

      • groovyguy's avatar
        groovyguy
        Champion Level 1

        Where are you running the script from?