cancel
Showing results for 
Search instead for 
Did you mean: 

Make all Data Source properties available to another called test case

SOLVED
Highlighted
Occasional Contributor

Make all Data Source properties available to another called test case

Using groovy, I know that I can run another test case from the current test case, and pass context properties from the current test case into it, like so:

 

 

// get reference to that case and run it
def testCase = testRunner.testCase.testSuite.project.getTestSuiteByName(targetSuiteName).getTestCaseByName(targetTestCaseName)

// get properties from caller and pass to callee
def contextMap = new StringToObjectMap( context )

testCase.run(contextMap, false )

 

But, it seems that the context properties do not include the data source properties (unless I've missed something). So, my called test case doesn't have access to those properties. 

 

Is there a way to make all of the data source properties available to the called test case?

 

Thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Manager

Re: Make all Data Source properties available to another called test case

Hi Pricedgp,

 

I suppose that you can use the put method to add values of DataSource properties to your contextMap. For example, here is how the code looks on my computer:

def contextMap = new StringToObjectMap( context )
def from = context.expand( '${JDBC Data#From}' )
contextMap.put("datasourceFrom", from)

Here is an article containing a description of the method:

http://docs.oracle.com/javase/6/docs/api/java/util/HashMap.html#put(K, V)

 

---------
Tanya Gorbunova
SmartBear Community Manager

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

View solution in original post

1 REPLY 1
Highlighted
Community Manager

Re: Make all Data Source properties available to another called test case

Hi Pricedgp,

 

I suppose that you can use the put method to add values of DataSource properties to your contextMap. For example, here is how the code looks on my computer:

def contextMap = new StringToObjectMap( context )
def from = context.expand( '${JDBC Data#From}' )
contextMap.put("datasourceFrom", from)

Here is an article containing a description of the method:

http://docs.oracle.com/javase/6/docs/api/java/util/HashMap.html#put(K, V)

 

---------
Tanya Gorbunova
SmartBear Community Manager

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

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
The new challenge is here!

Create a script to сhange an XPath Match assertion to a JSONPath Match assertion for the TechCorner tag!


Scripts created in July:
- A script to generate an email when an assertion fails
- A script to change the request body before sending it to the server
Top Kudoed Authors