Forum Discussion
Thanks for the response Rao !
The data I want to access is object and not string type. In one step(say Step 1) I am initializing the report object and then running another step(say Step 2) from Step 1. I want the report object from step 1 to be somehow accessible in step 2.
One more thing, What if Step 1 and Step 2 are in different test suites?
- PrashantS8 years agoNew Contributor
Hi Rao ! Let me share the script and rephrase the question based on your last response.
// step1 in suite 1
def extent = new ExtentReports(ResultExtentFileName,true)
def logger=extent.startTest("Test1")
logger.log(LogStatus.INFO,"Test1 Started !")desiredTestStep=testRunner.testCase.testSuite.project.testSuites["MainSuite"].testCases["Test2"].testSteps["Step2"] desiredContext=new WsdlTestRunContext(desiredTestStep)
WsdlTestCaseRunner desiredTestRunner = new WsdlTestCaseRunner(desiredTestCase, null);
//step2- this is in suite 2 but i am running this from step 1 in suite 1
status=desiredTestStep.run(desiredTestRunner,desiredContext)now I need the logger in step 2 being run by the statement above.
Please note that step 1 and step 2 are in separate test suites. I am able to achieve this if both steps are in same test suite.
Is it not possible if both steps are in separate test suites?
Is there any way to achieve this?
- nmrao8 years agoChampion Level 3It is already answered in the last 2 replies. Possible only if all the suites are run in the same context.
When the object is created, set it to context ie.,
context.logger = logger
In the later script, get it by:
def logger = context.logger
Disclaimer: You get null for the other instances if you run the scripts separately.
- sireeshas8 years agoNew Contributor
Hi Prashanth,
Did you figured the way to use the same object reference in two different groovy steps? If yes, could you please let me know how to achieve it.
Regards,
Sireesha S
- nmrao8 years agoChampion Level 3sireeshas
Have you gone thru the full reading of this thread? It has answer.
If that did not help, then post what you are trying to achieve with details?- sireeshas8 years agoNew Contributor
Oops.. I missed it some how..
I used context but in a wrong way.. Your example helped me to correct the mistake,
Thanks Rao
Related Content
Recent Discussions
- 15 years ago