Re: [Pyunit-interest] Using PyUnit with JPython to test-drive Java?
Brought to you by:
purcell
From: Tjitske H. en O. P. <th...@nl...> - 2000-10-02 11:14:14
|
Steve, Thanks for the hint. I've modified the unittest.py a little and it now works with JPython (text-only, but that's okay). Only remaining problem is the stacktrace for failures: it currently only shows the calls to unittest.py methods, not the call in the actual test routine or a trace through the Java sources that I'm testing. The problem was with the use of the "traceback" module in printNumberedErrors. I've modified it and it now looks like this: def printNumberedErrors(self,errFlavour,errors): if not errors: return if len(errors) == 1: self.stream.writeln("There was 1 %s:" % errFlavour) else: self.stream.writeln("There were %i %ss:" % (len(errors), errFlavour)) i = 1 for test,error in errors: self.stream.writeln("%i) %s" % (i, test)) # changes start here # errString = string.join(apply(traceback.format_exception,error),"") # self.stream.writeln(errString) errclass,errmsg,errstack = error errstackdump = java.lang.StringBuffer() errstack.dumpStack(errstackdump) self.stream.writeln("%s %s" % (errclass,errmsg)) self.stream.writeln("%s" % errstackdump) # end changes i = i + 1 But this is not yet perfect. Anyone a better solution here? Anyway, using JPython with PyUnit to test-drive Java is a much better solution than using JPython with JUnit. -Otto Perdeck > > [snip] I would prefer to use PyUnit to drive my Java classes. > > In the doc it is suggested that this isn't possible, but why is that? [snip] > > There are a few complications; I think they were mainly covered in a few mails > on this list a couple of months back. If you didn't already look, perhaps > you could look at the list archives and see if they answer your questions. > The interrelationship of JUnit and PyUnit together with JPython/CPython is > one of great interest to me. I have to admit that I'm currently doing Java > work with JUnit, and I'm writing the tests in Java. > > I'm trying to pick out aspects of JUnit v3 that might be useful in PyUnit, but > usually I prefer to keep things simple so that my poor brain can understand > them. > Steve Purcell, Pythangelist |