RE: [Grinder-development] new to grinder!!!!!!!!!!!!!!

"Philip Aston" <[email protected]> Thu, 5 Jan 2006 14:14:49 -0000
Newsgroups gmane.comp.java.grinder.announce
Message-ID <7553AA7A8AC280418AA6EC6949E0E40D078AEB1B__16463.9681614519$1136472289$gmane$org@ukhwex01.emea.bea.com>
In Python (and Jython, and scripts for The Grinder) structures are
delimited by indentation.
=20
E.g.
=20
def f():
     x=3D1 # Part of f()
     x=3Dx+1 # Also part of f()
x=3D2 # Not part of f()
=20
I suggest you familiarise yourself with the basics of Python
(http://diveintopython.org/) before proceeding further. This will also
teach you how to catch exceptions in Python.
=20
- Phil


________________________________

	From: grinder-development-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
[mailto:grinder-development-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf Of
anand vinoth
	Sent: 03 January 2006 12:39
	To: [email protected];
grinder-development-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org;
grinder-announce-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
	Subject: [Grinder-development] new to grinder!!!!!!!!!!!!!!
=09
=09
	hello friends, iam anand working in a software concern as java
Tester,iam new to grinder iam using Junit as a tool for my tests i found
griner as a tool for multithreading and it works really good but i need
to be expert in grinder,i have one doubt hope u will help me Thanks in
advance.following code is my grinder.py file and its working fine when i
tried enhancing its gives error iam not able to find out please help
me,i have pasted it below go through log files also.And onmore thing is
its not showing for errors.Actually i need to know what is the syntax i
should implement to catch the exception comes from the .java source
file.let me paste my simple java code also below i just written one src
file and testing it which returns a string.i want to print that result
in file in grinder and too i need to know how to catch throwed exception
in grinder?
	=20
	grinder.py file:
	=20
		from net.grinder.script import Test
	from net.grinder.script.Grinder import grinder
	from java.lang import String
	from com.kstc.test import Testhelloworld
	=20
	test1 =3D Test(1, "JUnit HelloWorld Test")
	th1 =3D test1.wrap(Testhelloworld())
	=20
	class TestRunner:
	def __call__(self):
	result=3Dth1.testhelloworld()=20
	=20
	when i tried to get the out put  of the result and print it in
the file its not working giving error Invalid Syntax.the following is
the code:
	=20
		from net.grinder.script import Test
	from net.grinder.script.Grinder import grinder
	from java.lang import String
	from com.kstc.test import Testhelloworld
	=20
	test1 =3D Test(1, "JUnit HelloWorld Test")
	th1 =3D test1.wrap(Testhelloworld())
	=20
	def writeToFile(text):
	filename =3D grinder.getFilenameFactory().createFilename(
	"page", "-%d.html" % grinder.runNumber)
	file =3D open(filename, "w")
	print >> file, text
	file.close()
	=20
	class TestRunner:
	def __call__(self):
	statistics =3D grinder.statistics
	result=3Dth1.testhelloworld()=20
	grinder.logger.output("The last test took %d milliseconds" %
statistics.time)=20
	try:=20
	writeToFile(result)
	except IoError, ioe:
	grinder.logger.output("Exception :" ,ioe)=20
		=20
	=20
	please find the Error_log file :
	=20
	1/3/06 5:57:23 PM (process ): Error running worker process
(Jython error encountered initialising test script)
	net.grinder.engine.process.JythonScriptExecutionException: J
ython error encountered initialising test script
	 at
net.grinder.engine.process.JythonScript.<init>(JythonScript.java:81)
	 at
net.grinder.engine.process.GrinderProcess.run(GrinderProcess.java:223)
	 at
net.grinder.engine.process.GrinderProcess.main(GrinderProcess.java:109)
	Caused by: Traceback (innermost last):
	  (no code object) at line 0
	SyntaxError: ('inconsistent dedent',
('E:\\Projects\\Grinder\\grinder.py', 20, 8, '
grinder.logger.output("The last test took %d milliseconds" %
statistics.time)                           '))
	 at org.python.core.parser.fixParseError(parser.java)
	 at org.python.core.parser.parse(parser.java)
	 at org.python.core.Py.compile_flags(Py.java)
	 at org.python.core.__builtin__.execfile_flags(__builtin__.java)
	 at
org.python.util.PythonInterpreter.execfile(PythonInterpreter.java)
	 at
net.grinder.engine.process.JythonScript.<init>(JythonScript.java:78)
	 ... 2 more
=09
	=20
	My java Code and Testing :
	=20
	import junit.framework.Assert;
	import junit.framework.TestCase;
	/*
	 * Created on Dec 23, 2005
	 *
	 * TODO To change the template for this generated file go to
	 * Window - Preferences - Java - Code Style - Code Templates
	 */

	/**
	 * @author Administrator
	 *
	 * TODO To change the template for this generated type comment
go to
	 * Window - Preferences - Java - Code Style - Code Templates
	 */
	public class Testhelloworld extends TestCase {
	=20
	 public void setup(){ =20
	 }
	=20
	 public String testhelloworld(){ =20
	  Example e =3D new Example();
	  String actual =3D e.displayHello();
	  String expected =3D "Successful";
	  testpass(actual,expected);
	  return actual;
	 }
	=20
	 private void testpass(String actual,String expected) {
	  try {  =20
	   Assert.assertEquals(expected,actual);
	   System.out.println("TESTCASE SUCCEEDED");
	  }catch (Error e){
	   System.out.println("TESTCASE FAILED");
	   throw e ;
	  } =20
	 }
	 public static void main(String[] args) {
	  new Testhelloworld().testhelloworld();
	//  junit.textui.TestRunner.run(Testhelloworld.class);
	 }
	=20
	 class Example {
	  public  void main(String args[]) {
	   System.out.println("Hello World :");
	  }
	 =20
	  public String displayHello() {
	   System.out.println("Hello World :");
	   return "Successful";
	  }
	 }
	}
=09
	=20
=09
	________________________________

	Yahoo! Shopping
	Find Great Deals on Holiday Gifts at Yahoo! Shopping
<http://us.rd.yahoo.com/mail_us/footer/shopping/*http://shopping.yahoo.c
om/;_ylc=3DX3oDMTE2bzVzaHJtBF9TAzk1OTQ5NjM2BHNlYwNtYWlsdGFnBHNsawNob2xpZG=
F
5LTA1> =20




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click