cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
PrakashKannan
Contributor

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
}
}

1 ACCEPTED SOLUTION

Accepted Solutions
msiadak
Community Hero

Re: Disabling test case in set up script is not working

Try this:

 

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



---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!

View solution in original post

9 REPLIES 9
msiadak
Community Hero

Re: Disabling test case in set up script is not working

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;
		}
	}
}



---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
PrakashKannan
Contributor

Re: Disabling test case in set up script is not working

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

msiadak
Community Hero

Re: Disabling test case in set up script is not working

Where are you running the script from?




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
PrakashKannan
Contributor

Re: Disabling test case in set up script is not working

It is from Setup Script

msiadak
Community Hero

Re: Disabling test case in set up script is not working

Try this:

 

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



---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!

View solution in original post

PrakashKannan
Contributor

Re: Disabling test case in set up script is not working

It says 'No such property:testSuite for the class' and for your information I am running set up script at project level. 

PrakashKannan
Contributor

Re: Disabling test case in set up script is not working

Modified the script and worked. Thank you so much.

 

project.getTestSuiteList().each{
def testCaseList=it.getTestCaseList()
testCaseList.each{
if(it.getName().contains("_xsi"))
{
it.disabled=true
}
}
}

msiadak
Community Hero

Re: Disabling test case in set up script is not working

I am glad you got it working! I assumed it was at the test suite level which was bad on my part. 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
PrakashKannan
Contributor

Re: Disabling test case in set up script is not working

I too missed to provide that information. Thanks!

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors