Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jython and Unit testing

 
Burk Hufnagel
Ranch Hand
Posts: 814
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Matthew X. Brown
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Burk Hufnagel
Ranch Hand
Posts: 814
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Laurent Ploix
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic