Hi,
I would like to measure the transaction time of one function which I defined inside the class.. In the following class, I wanted to measure only test_greeting function. I also need to verify the value which was returned by test_greeting. When I run the test, I am getting the following error. net.grinder.scriptengine.jython.JythonScriptExecutionException: Java exception calling TestRunner grinder.statistics.forLastTest.success = success File "${NGRINDER_HOME}/script/user/Test_Wrap.py", line 28, in __call__ net.grinder.script.InvalidContextException: No tests have been performed by this thread. #Test_wrap.py from net.grinder.script import Test from net.grinder.script.Grinder import grinder from java.util import Date from java.text import SimpleDateFormat from java.lang import String from java.util import Random, Properties log = grinder.logger.info class TestRunner: def test_Greeting(self, strMsg): grinder.sleep(1000) return strMsg def __init__(self): grinder.statistics.delayReports=True self.do_request_test = Test(1, "Perform service request").wrap(self.test_Greeting) log("Thread starting up") pass def __call__(self): replyMessage = None success = 0 replyMessage = self.do_request_test("Hi") if replyMessage == "Hi": success = 1 grinder.sleep(1000) grinder.statistics.forLastTest.success = success def __del__(self): log("Thread shutting down") Can any of you please suggest me whether I am doing it properly?.. Is there any other way to achieve this? Regards, Balaji |
Administrator
|
You should write a script like this.
#Test_wrap.py
do_request_test = Test(1, "Perform service request").wrap(test_Greeting)
log = grinder.logger.info class TestRunner: if replyMessage == "Hi":
-----Original Message----- If you reply to this email, your message will be added to the discussion below:
http://ngrinder.642.n7.nabble.com/Wrap-function-usage-in-Grinder-tp309.html
To start a new topic under ngrinder-user-en, email [hidden email]
To unsubscribe from ngrinder-user-en, click here. NAML |
Hi Junoyoon, Thanks for your quick response.. Is there any way to measure function which I defined inside TestRunner class?..On Wed, Feb 13, 2013 at 3:58 PM, junoyoon [via ngrinder] <[hidden email]> wrote:
Test_01.py (9K) Download Attachment |
Administrator
|
If so, you should pass the current instance as parameter of the method.. like..
def method_to_be_measured(runner, strMsg) : runner.method1()
def method_to_be_measured2(runner, strMsg) : runner.method2()
class TestRunner... def __call__(self): method_to_be_measured(self, "WOW"); def method1(self) : .....
-----Original Message----- Hi Junoyoon, Thanks for your quick response.. Is there any way to measure function which I defined inside TestRunner class?.. On Wed, Feb 13, 2013 at 3:58 PM, junoyoon [via ngrinder] <[hidden email]> wrote:
Test_01.py (9K) Download Attachment If you reply to this email, your message will be added to the discussion below:
http://ngrinder.642.n7.nabble.com/Wrap-function-usage-in-Grinder-tp309p311.html
To start a new topic under ngrinder-user-en, email [hidden email]
To unsubscribe from ngrinder-user-en, click here. NAML |
Thanks a lot.. For time being, I created a separate class and I defined all my functions inside that.. Now everything is working fine.. I tried the runner method like below but didn't work.. Can you please confirm whether I used runner method properly?.from net.grinder.script import Test from net.grinder.script.Grinder import grinder from java.util import Date from java.text import SimpleDateFormat from java.lang import String from java.util import Random, Properties log = grinder.logger.info def method_to_be_measured(runner, strMsg) : runner.test_Greeting(strMsg) test1 = Test(1,"test1").wrap(method_to_be_measured) class TestRunner: def test_Greeting(self, strMsg): grinder.sleep(1000) log("Inside greeting") log(strMsg) return strMsg def __init__(self): grinder.statistics.delayReports=True log("Thread starting up") pass def __call__(self): replyMessage = None success = 0 replyMessage = test1(self,"WOW"); if replyMessage == "WOW": success = 1 grinder.sleep(1000) grinder.statistics.forLastTest.success = success def __del__(self): log("Thread shutting down") On Wed, Feb 13, 2013 at 4:19 PM, junoyoon [via ngrinder] <[hidden email]> wrote:
|
Administrator
|
You should fix the following method
def method_to_be_measured(runner, strMsg) : runner.test_Greeting(strMsg) like this. def method_to_be_measured(runner, strMsg) : return runner.test_Greeting(strMsg) |
Thanks again.. The script is working now.. On Thu, Feb 14, 2013 at 1:33 AM, junoyoon [via ngrinder] <[hidden email]> wrote: You should fix the following method |
Free forum by Nabble | Edit this page |