Forum Discussion
8 Replies
Sort By
- MOTOROLA_Suppor_1ContributorI am still wait from support to help me on this.
- SmartBear_SuppoSmartBear Alumni (Retired)Hello,
Try this:
runner.mockContext.setProperty("myLogFile", "hello world")
Regards,
Dain
eviware.com - MOTOROLA_Suppor_1ContributorDain,
thanks for your response but I am not sure I have complete solution as you suggested. How do I get this property from onMockResult() Do I have access to runner object ?
In onMockResult, I have result object but not sure how to get runner object
sheena - SmartBear_SuppoSmartBear Alumni (Retired)Hello Sheena,
Sorry, I missed that part of your original question. You can access the context from the result object by calling:
def context = result.mockRequest.context
log.info context.myLogFile
Regards,
Dain
eviware.com - MOTOROLA_Suppor_1ContributorHi, Dain,
I copied the my script here, not sure what is wrong but I could not get the mock request logged into my file. I could not even find file in the expected directory.
thanks
sheena
===MockRunListener.moMockRunnerStart===========
def logfile = "D:/XML-Testing/WebNBI/SoapUIPro/TestResultR7.3/MyMockLogFile.log";
log.info(logfile);
def File myMockFile = new File(logfile);
myMockFile.append("this is a test");
log.info(myMockFile);
if ( myMockFile.exists()) {
myMockFile.delete()
myMockFile = new File(logfile);
}
runner.mockContext.setProperty("MyMockLogFile", myMockFile);
===MockRunListener.onMockResult
if ( result ) {
def mockReq = result.getMockRequest()
def context = result.mockRequest.context;
if ( context.MyMockLogFile) {
def filehandle = context.myMockLogFile;
filehandle.append ( mockReq.getRequestContent())
log.info("Has Mock Log file");
}
log.info(mockReq.getRequestContent());
} - MOTOROLA_Suppor_1ContributorCan some one from customer support to help on what is wrong with my scripts ? Help needed.
- SmartBear_SuppoSmartBear Alumni (Retired)Hi!
it seems you have a typo in your onResult script;
def filehandle = context.myMockLogFile;
should be
def filehandle = context.MyMockLogFile;
(capital M in the property name)
Does that help?
regards!
/Ole
eviware.com - MOTOROLA_Suppor_1ContributorOle, Thank you so much. It does work now. Somehow, I just did not catch the typo and script language is not strong at type/syntax chechking. thanks again.
sheena
Related Content
- 4 years agosparrowenclave