cancel
Showing results for 
Search instead for 
Did you mean: 

SoapUI - How to use the context variable set in test suite at the test case

New Contributor

SoapUI - How to use the context variable set in test suite at the test case

Hello!

Is there any way I can use the context variable set in test suite at the test case.

 

Thanks

6 REPLIES 6
Community Hero

Re: SoapUI - How to use the context variable set in test suite at the test case

How about this?

context.testCase.testSuite.setPropertyValue('name', 'value')


Regards,
Rao.
New Contributor

Re: SoapUI - How to use the context variable set in test suite at the test case

I want to pass a variable that is defined in test suite with value as an Object and use in the subsequent test cases.

For eg. My test suite has set up script which defines a context variable as follows
context.testSuiteVariable = new HelloWorld()

I want to use this context.testSuiteVariable in my test case. Any idea how to achieve this?
Highlighted
Community Hero

Re: SoapUI - How to use the context variable set in test suite at the test case

@sumeet0420 

 

You can simply use

context.testSuiteVariable

 

If you want an example, here you go:

Selection_034.png



Regards,
Rao.
Community Leader

Re: SoapUI - How to use the context variable set in test suite at the test case

Hi @sumeet0420 ,

 

In your TestSuite you can assign value to context variable by below:

context.setProperty("varName", varValue);

And in your TestCase, you can use the value by below:

log.info context.varName

Click "Accept as Solution" if my answer has helped, and remember to give "kudos" Smiley Happy

Thanks and Regards,
Himanshu Tayal
New Contributor

Re: SoapUI - How to use the context variable set in test suite at the test case

Hi,

This will not work as TestSuite context is different from TestCase object.

Test Case Context is an instance of TestCaseRunContext while Test Suite Context is an instance of TestSuiteRunContext.
Community Hero

Re: SoapUI - How to use the context variable set in test suite at the test case

I could not related your response to which reply.

Can you provide more details?
Have you tried the given solution before saying this will not work?


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Top Kudoed Authors