Hello, to simplify my problem, I have a file containing a TestRunner class that looks like this:
sys.path.append('./') from net.grinder.script.Grinder import grinder from dummyTest import DummyTest dummyTest = DummyTest() class TestRunner: def __init__(self): grinder.statistics.delayReports=True pass def __call__(self): print grinder.getThreadNumber() print grinder CookieModule.discardAllCookies() dummyTest.performTests() CookieModule.discardAllCookies() and a DummyTest class that looks like this: from net.grinder.script import Test from net.grinder.script.Grinder import grinder class DummyTest: def __init__(self): self.firstTestWrapper = Test(1, "Blahblah").wrap(self.firstTest) self.secondTestWrapper = Test(2, "Blahblahblah").wrap(self.secondTest) def firstTest(self, arg): print arg return True def secondTest(self, arg): print arg return True def performTests(self): print grinder.getThreadNumber() print grinder firstTestResult = self.firstTestWrapper("first test running") grinder.statistics.forLastTest.success = firstTestResult secondTestResult = self.secondTestWrapper("second test running") grinder.statistics.forLastTest.succes = secondTestResult When printing out the thread number and the grinder context instance number, i get the same values for the inside of the __call__ function in the TestRunner class and the inside of the performTests function of the DummyTest class. The print output is something like this: 2014-05-12 11:36:58,875 INFO agent: worker PRGLAPJ78ZVZ1-0 started 2014-05-12 11:37:02,152 INFO PRGLAPJ78ZVZ1-0: starting threads 0 net.grinder.engine.process.ScriptContextImplementation@2fbb3e9a 0 net.grinder.engine.process.ScriptContextImplementation@2fbb3e9a first test running 2014-05-12 11:37:02,199 INFO PRGLAPJ78ZVZ1-0: finished 2014-05-12 11:37:02,546 INFO agent: finished However, the script stops at the grinder.statistics.forLastTest.success = firstTestResult line and gives me the following exception: 2014-05-12 11:37:02,187 ERROR PRGLAPJ78ZVZ1-0 thread-0 [ run-0 ]: aborted run - Java exception calling TestRunner net.grinder.scriptengine.jython.JythonScriptExecutionException: Java exception calling TestRunner grinder.statistics.forLastTest.success = firstTestResult File ".\dummyTest.py", line 23, in performTests dummyTest.performTests() File ".\dssPki_tests_perf.py", line 43, in __call__ net.grinder.script.InvalidContextException: No tests have been performed by this thread. at net.grinder.engine.process.ScriptStatisticsImplementation.getForLastTest(ScriptStatisticsImplementation.java:130) ~[grinder-core-3.11.jar:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_45] at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_45] at org.python.core.PyBeanProperty._doget(PyBeanProperty.java:33) ~[jython.jar:na] at org.python.core.PyObject._doget(PyObject.java:1072) ~[jython.jar:na] at org.python.core.PyObject.__get__(PyObject.java:3674) ~[jython.jar:na] at org.python.core.PyObject.object___findattr__(PyObject.java:3706) ~[jython.jar:na] at org.python.core.PyObject.object___getattribute__(PyObject.java:3690) ~[jython.jar:na] at org.python.core.PyObject$object___getattribute___exposer.__call__(Unknown Source) ~[jython.jar:na] at org.python.core.Deriveds.__findattr_ex__(Deriveds.java:59) ~[jython.jar:na] at org.python.core.PyObjectDerived.__findattr_ex__(PyObjectDerived.java:983) ~[jython.jar:na] at org.python.core.PyObject.__getattr__(PyObject.java:923) ~[jython.jar:na] at dummyTest$py.performTests$5(.\dummyTest.py:25) ~[na:na] at dummyTest$py.call_function(.\dummyTest.py) ~[na:na] at org.python.core.PyTableCode.call(PyTableCode.java:165) ~[jython.jar:na] at org.python.core.PyBaseCode.call(PyBaseCode.java:134) ~[jython.jar:na] at org.python.core.PyFunction.__call__(PyFunction.java:317) ~[jython.jar:na] at org.python.core.PyMethod.__call__(PyMethod.java:109) ~[jython.jar:na] at org.python.pycode._pyx1.__call__$4(.\dssPki_tests_perf.py:50) ~[na:na] at org.python.pycode._pyx1.call_function(.\dssPki_tests_perf.py) ~[na:na] at org.python.core.PyTableCode.call(PyTableCode.java:165) ~[jython.jar:na] at org.python.core.PyBaseCode.call(PyBaseCode.java:301) ~[jython.jar:na] at org.python.core.PyBaseCode.call(PyBaseCode.java:194) ~[jython.jar:na] at org.python.core.PyFunction.__call__(PyFunction.java:387) ~[jython.jar:na] at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:220) ~[jython.jar:na] at org.python.core.PyMethod.__call__(PyMethod.java:211) ~[jython.jar:na] at org.python.core.PyMethod.__call__(PyMethod.java:206) ~[jython.jar:na] at org.python.core.PyObject.invoke(PyObject.java:3555) ~[jython.jar:na] at org.python.core.PyInstance.instance___call__(PyInstance.java:351) ~[jython.jar:na] at org.python.core.PyInstance.__call__(PyInstance.java:342) ~[jython.jar:na] at org.python.core.PyObject.__call__(PyObject.java:371) ~[jython.jar:na] at net.grinder.scriptengine.jython.JythonScriptEngine$JythonWorkerRunnable.run(JythonScriptEngine.java:263) ~[grinder-core-3.11.jar:na] at net.grinder.engine.process.GrinderThread.run(GrinderThread.java:119) ~[grinder-core-3.11.jar:na] at java.lang.Thread.run(Thread.java:662) [na:1.6.0_45] The line numbers in the file with the TestRunner class and the file with the DummyTest class do not match as the files have been simplified for clarity reasons. Any clue why this exception appears? |
Administrator
|
Could you modify it like following? from net.grinder.script.Grinder import grinder from dummyTest import DummyTest Test(1, "Blahblah").record(DummyTest.firstTest)
Test(2, "Blahblahblah").record(DummyTest.secondTest) dummyTest = DummyTest() class TestRunner: def __init__(self): grinder.statistics.delayReports=True pass def __call__(self): print grinder.getThreadNumber() print grinder CookieModule.discardAllCookies() dummyTest.performTests() CookieModule.discardAllCookies() from net.grinder.script import Test from net.grinder.script.Grinder import grinder class DummyTest: def firstTest(self, arg): print arg return True def secondTest(self, arg): print arg return True def performTests(self): print grinder.getThreadNumber() print grinder grinder.statistics.forLastTest.success = self.firstTest("first test running") grinder.statistics.forLastTest.success = self.secondTest("second test running") 2014-05-12 18:50 GMT+09:00 atgcko [via ngrinder] <[hidden email]>: Hello, to simplify my problem, I have a file containing a TestRunner class that looks like this: |
Free forum by Nabble | Edit this page |