Question

I was started using grinder tool, when ever i run my script i get the following error.

ImportError: No module named net.grinder.script. Grinder

This is the script that i am trying to run

# A minimal script that tests The Grinder logging facility.
#
# This script shows the recommended style for scripts, with a
# TestRunner class. The script is executed just once by each worker
# process and defines the TestRunner class. The Grinder creates an
# instance of TestRunner for each worker thread, and repeatedly calls
# the instance for each run of that thread.

  from net.grinder.script.Grinder import grinder
  from net.grinder.script import Test

# A shorter alias for the grinder.logger.info() method.
  log = grinder.logger.info

# Create a Test with a test number and a description. The test will be
# automatically registered with The Grinder console if you are using
# it.
  test1 = Test(1, "Log method")

# Instrument the info() method with our Test.
  test1.record(log)

# A TestRunner instance is created for each thread. It can be used to
# store thread-specific data.
 class TestRunner:

# This method is called for every run.
 def __call__(self):
    log("Hello World")

When ever run this script i get the Import Error.

I have set the CLASSPATH and JAVA_HOME environment variables also. Can anyone help me out.

Was it helpful?

Solution

Setting the class path was a bit tricky , I did the following on mac(10.6.8) terminal before running the java command provided by Philp above :

ClassPath Setting :(execute this one after other on the terminal )

    export JAVA_VERSION=1.6
    export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    export GRINDERPATH=/Users/cdname/grinder-3.11
    export CLASSPATH=$GRINDERPATH/lib/grinder.jar:$CLASSPATH
    export PATH=$JAVA_HOME/bin:$PATH
    java -classpath $CLASSPATH net.grinder.Grinder

I included this to /etc/launchd.conf, and run grep -E "^setenv" /etc/launchd.conf | xargs -t -L 1 launchctl

In the grinder.properties file set : grinder.useConsole = false

Now run the .py file:

     java -Dgrinder.script=csaTest.py net.grinder.Grinder

OTHER TIPS

It appears to me that you are trying to run the script directly using Jython. You should run the script using The Grinder.

If you've set the classpath correctly, and the script file is in the local directory and named helloworld.py, then

java -Dgrinder.script=helloworld.py net.grinder.Grinder

should start an agent, run one worker process, and execute your script once.

can you cross check with the details posted by me @

http://stackoverflow.com/questions/19148365/cant-run-grinder-java-test-framework/19429771#19429771

It seems to be path issue. If none of the solution above works, try to manually set the path using 'sys.path()' & print it inside a sample Jython script & paste the output here

print sys.path
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top