Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Jython/Python and the fly likes Jython and Unit testing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Jython/Python
Bookmark "Jython and Unit testing" Watch "Jython and Unit testing" New topic
Author

Jython and Unit testing

Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
I like the idea that I can write Jython scripts and access my Java classes and I was wondering if anybody's got experience with a tool like JUnit but written in Jython?
Is it worth digging into, or is JUnit good enough by itself?
Thanks,
Burk


SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
Matthew X. Brown
Ranch Hand

Joined: Nov 08, 2000
Posts: 165
Have you tried to do imports using the jython java import functions- I might try to import my junit classes and open up the implementation- conceivably- you could build, using the reflection API, a class that could allow you to pass in the jython classes you wanted to validate in a Junit "proxy" class.
Glenn Murray
Ranch Hand

Joined: Dec 07, 2001
Posts: 74
I have the same question and would like to hear
from the wizards regarding this. In particular
I'm wondering about automating GUI testing,
which I've found to be very difficult.
Thanks,
Glenn


Glenn Murray
Author of Yo Soy Una Vaca De Hoy
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
That's a neat idea I hadn't thought of. Use JUnit to unit test the Jython code. Mind if I borrow it?
Originally posted by Matthew Brown:
Have you tried to do imports using the jython java import functions- I might try to import my junit classes and open up the implementation- conceivably- you could build, using the reflection API, a class that could allow you to pass in the jython classes you wanted to validate in a Junit "proxy" class.
Robert W Bill
Author
Greenhorn

Joined: Apr 08, 2002
Posts: 21
Here's some chat about unit testing and Jython from the Jython users mailing list.
http://sourceforge.net/mailarchive/forum.php?thread_id=626750&forum_id=5586
Justin Steadham
Greenhorn

Joined: Jul 30, 2002
Posts: 1
I use pyunit extensively for unit testing an EJB application. It's the bomb and I recommend you take some time to learn python to fully utilize this amazing tool! The only problem is it's easy to get addicted to python/jython. I'm trying to learn .NET and I'm not thrilled I've got to give up the interactive console I've grown to love - lol.
If you know already know java, python is cake.
For info on pyunit:
http://pyunit.sourceforge.net/
http://pyunit.sourceforge.net/pyunit.html#USING
General python links:
http://www.dickbaldwin.com/tocpyth.htm
I also recommend Jython Essentials as an excellent reference.
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
we are usign cactus to test EJBs.
We have EJBLocal interfaces.
Looks like pyunit is python version of junit.
I guess we can'tuse juint to test EJBLocal interfaces. Can you tell me how can i
use pyunit for testing EJBs?
I understand python so that is not a problem.
thanks!
karthik
Originally posted by Justin Steadham:
I use pyunit extensively for unit testing an EJB application. It's the bomb and I recommend you take some time to learn python to fully utilize this amazing tool! The only problem is it's easy to get addicted to python/jython. I'm trying to learn .NET and I'm not thrilled I've got to give up the interactive console I've grown to love - lol.
If you know already know java, python is cake.
For info on pyunit:
http://pyunit.sourceforge.net/
http://pyunit.sourceforge.net/pyunit.html#USING
General python links:
http://www.dickbaldwin.com/tocpyth.htm
I also recommend Jython Essentials as an excellent reference.
Andrew Glover
author
Greenhorn

Joined: Dec 19, 2002
Posts: 16
if you'd like to test your EJB code, you need to use Jython, not Python. With Jython you can use regular java objects. Jython can use Python code- hence the pyunit reference.


Certified City Slicker
Laurent Ploix
Greenhorn

Joined: Dec 05, 2003
Posts: 4
Answer to the original question about writing Junit tests in Jython.

Yes it is possible (and done).

We wrote an article about it on DevX. Now the classes are may be somewhat obsolete but they work.

http://www.devx.com/Java/Article/26602

You will find updated classes here on the blog : http://lauploix.blogspot.com/2005/03/test-driven-development-why-using.html

Then, last but not lease, we will gather the useful classes in the project : http://sourceforge.net/projects/crosstest/ (the project is still, well, pre alpha... give us a few weeks, it will be ok).
[ May 28, 2005: Message edited by: Laurent Ploix ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jython and Unit testing
 
Similar Threads
Any Jython in Action?
Any Resources for Jython ?
JUnit Testing
What do you think of Ruby/Rails?
This is for Mr Author--Bill