From: Oti <oh...@ya...> - 2003-03-13 07:39:55
|
[ Albert Anders ] > I am considering Jython to develop unit test cases for testing > our > Java public APIs. I believe it will significantly increase > productivity of > unit test development and will be easier to understand and support > over > the long run. Yes ! > All of our unit test drivers are currently written in Java and each > test > method is called from JUnit. In our test setup, each unit test > driver > extends from junit.framework.TestCase and JUnit (TestRunner) uses > reflection to find and run all methods that start with "test". > > I am having difficult figuring out the best and simplest way to use > JUnit > with my Jython classes. For each test unit driver, I would like to > write > a single Jython class that has multiple test methods. Ideally, the > Jython > class would extend from junit.framework.TestCase and it would be > passed > into the TestRunner.run( ) method. A possible solution can be found here (the second entry contains a little cookbook) http://aspn.activestate.com/ASPN/Mail/Message/1103677 http://aspn.activestate.com/ASPN/Mail/Message/1158472 That's the way we did it, and we are very productive with it. You may find others searching in the archieves. > The problem (I think?) is that in order for the methods in the Jython > class to be callable from the JUnit Java class, it is necessary to > define > the method signature using the docstring: > > Example: def testFunction(self): > "@sig public void testFunction()" No, if you use embedding. > And the Jython class must extend from a Java class such as > java.lang.Object. In this case it cannot extend from both > junit.framework.TestCase and java.lang.Object. junit.framework.TestCase already extends java.lang.Object So this is not a problem. > The only solution I can come up with is to write a Java wrapper class > that > extends from junit.framework.TestCase and have JUnit call the wrapper > class test methods. Within each test method it will instantiate the > associated Jython class and invoke the associated Jython test method. > This seems like a lot of work in order to be able to call the Jython > class > methods from a JUnit framework. It requires a Java wrapper method > for > each Jython test method. > > Has anyone implemented the JUnit test harness with Jython? Is there a > better / simpler approach than using a Java wrapper class? Hopefully I was able to show a possible approach. Best wishes, Oti. __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com |