cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the tag name assigned to a test case using a Ready API groovy script?

SOLVED
chico-uspto
Occasional Contributor

How to get the tag name assigned to a test case using a Ready API groovy script?

I would appreciate your help. I am using Ready! API version 2.1.

1 ACCEPTED SOLUTION

Accepted Solutions
Nastya_Khovrina
Moderator

Re: How to get the tag name assigned to a test case using a Ready API groovy script?

 Hi,

 

Thank you for your post! There are the following methods for working with tags:
at the project level: 
* getTags()
* getTagId("TagName")
* getTagById(TagId)
at the testCase level: 
* hasTags()
* getTagIds()
* isTagAssigned(String tagId)
Documentation: ​
Class WsdlTestCase: https://www.soapui.org/apidocs/com/eviware/soapui/impl/wsdl/testcase/WsdlTestCase.html
Class WsdlProject: https://www.soapui.org/apidocs/com/eviware/soapui/impl/wsdl/WsdlProject.html

So, you can get tag names for a test case with the following script in the Groovy Script Test Step:

import com.eviware.soapui.impl.wsdl.WsdlProject
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase

def project = context.getTestCase().getTestSuite().getProject();
def testCase = context.getTestCase()

log.info testCase.hasTags()
log.info testCase.getTagIds()

def testCaseTagIdList =  testCase.getTagIds()
for (testCaseTagId in testCaseTagIdList) {
   log.info project.getTagById(testCaseTagId)
}


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

2 REPLIES 2
Nastya_Khovrina
Moderator

Re: How to get the tag name assigned to a test case using a Ready API groovy script?

 Hi,

 

Thank you for your post! There are the following methods for working with tags:
at the project level: 
* getTags()
* getTagId("TagName")
* getTagById(TagId)
at the testCase level: 
* hasTags()
* getTagIds()
* isTagAssigned(String tagId)
Documentation: ​
Class WsdlTestCase: https://www.soapui.org/apidocs/com/eviware/soapui/impl/wsdl/testcase/WsdlTestCase.html
Class WsdlProject: https://www.soapui.org/apidocs/com/eviware/soapui/impl/wsdl/WsdlProject.html

So, you can get tag names for a test case with the following script in the Groovy Script Test Step:

import com.eviware.soapui.impl.wsdl.WsdlProject
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase

def project = context.getTestCase().getTestSuite().getProject();
def testCase = context.getTestCase()

log.info testCase.hasTags()
log.info testCase.getTagIds()

def testCaseTagIdList =  testCase.getTagIds()
for (testCaseTagId in testCaseTagIdList) {
   log.info project.getTagById(testCaseTagId)
}


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

chico-uspto
Occasional Contributor

Re: How to get the tag name assigned to a test case using a Ready API groovy script?

Great! This is exactly what I was looking for. It worked and implemented in my scripts.

Regards, /Chico

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