Accessing Test Case Property in Project's TearDown script
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Accessing Test Case Property in Project's TearDown script
Hi All,
I was looking for groovy script to access property from test cases in the TearDown script (of Project)
On doing GetData simply returns " context.expand( '${#TestCase#TCCount}' )" [TCCount is the name of property]
I have multiple testcases but GetData returns TestCase when I try to load using ReadyAPI feature.
That's probably a bug in ReadyAPI
I tried by providing testcase name in place of "TestCase" but it does not return anything.
Can someone please provide an answer incase they have used this.
Thanks !
Solved! Go to Solution.
- Labels:
-
Automation Environments
-
REST
-
Scripting
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I dont know if I'm misunderstanding - but are you saying that you are unable to reference a property from another test case?
I don't know if the following will help, but
If it didn't pick up the property associated with the other test case - was you prefixing the testcase name with the testsuite prefix?
I believe if you use the syntax as follows:
context.expand( '${#TestCase#property1}' )
The '#TestCase#' is actually specifying the level where the property is - not it's actual name.
If you want to specify the TestCase name here - try the following:
context.expand( '${#[TestSuite Name#TestCase Name]#property}' )
Essentially i'm wondering if you specify the testsuite as well this might help?
richie
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
Thank you for your time looking into this, @richie!
@SuperSingh, have you had a chance to try what richie suggested? If his guess was right and this helps you accomplish your task, could you please mark the above reply as a Solution? This will help other users find it faster when searching for the answer. Thank you in advance.
Olga Terentieva
SmartBear Assistant Community Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @richie
Thanks for your time in giving the reply. The syntax you shared works when I put it individually.
But I want to extract it from all the test cases. For e.g. if I have 5 testcases, I want to loop through all and extract the TCCount from their properties.
The following piece of code doesn't work. But this is what I am looking to extract .
testSuite.testCaseList.each {
def name = "${it.name}"
log.info name
def tCCount = context.expand( '${'$name'#TCCount}' )
log.info tCCount
}
Thanks again for your time .
Regards,
SuperSingh
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What you have shown is the Teardown Script of Test suite, but not the project level Teardown.
/** * Below is the Teardown Script of the Test Suite * which looks for the given property in all the test cases of the same suite * and logs the value **/ //Specify your property name in below statement def propertyName = 'Property1' testSuite.testCaseList.each { kase -> if (kase.hasProperty(propertyName)) { log.info "${testSuite.name} suite, ${kase.name} case, ${propertyName} value is ${kase.getPropertyValue(propertyName)}" } }
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the code, Rao.
@SuperSingh, is this what you are looking for?
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
