Pregunta

Grinder is new for me and I am trying to figure out how to get rid of this error:

my test.py script:

import string
import random
from java.lang import String
from java.net import URLEncoder
from net.grinder.plugin.http import HTTPRequest
from net.grinder.common import GrinderException

log = grinder.logger.info
stat = grinder.statistics.forLastTest

SERVER = "http://www.google.com"
URI = "/"

class TestRunner:
        def __call__(self):
                requestString = "%s%s" % (SERVER, URI)
                request = HTTPRequest()
                result = request.GET(requestString)
                if string.find(result.getText(), "SUCCESS") < 1:
                        stat.setSuccess(0)

I run

java net.grinder.Console
java net.grinder.Grinder

in my localhost. after starting the test, this message keeps popping up:

aborting process - Jython exception, <type 'exceptions.NameError'>: name 'grinder' is not defined [initialising test script]
net.grinder.scriptengine.jython.JythonScriptExecutionException: <type 'exceptions.NameError'>: name 'grinder' is not defined
    log = grinder.logger.info
    File "./test.py", line 8, in <module>

It looks like I have to include some Grinder module for this "grinder.logger.info" but I just have no clue of what I should import... ...

Any hint?

Thanks in advance

¿Fue útil?

Solución

you imported items from grinder, not grinder itself, try

import grinder.logger.info
import grinder.statistics.forLastTest

it might also be net.grinder.logger.info and net.grinder.statistics.forLastTest if this is the case then your code will need changing to go with the change from grinder to net.grinder

Otros consejos

You have not imported grinder.

from net.grinder.script.Grinder import grinder

and now try again.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top