[Zope-Coders] Unit Testing Framework?
Shane Hathaway
shane@zope.com
Mon, 12 Aug 2002 12:51:44 -0400
Lennart Regebro wrote:
> While we are on the subject of unit tests. I love unit tests, but I think
> they are a pain to do under Zope, and you need to know a lot of how Zope
> works under the hood. And even I, who do know quite a bit, are confused.
>
> I would like to see something that makes it easier to make unit tests for
> Zope. Maybe a framework that helps you to set up the environment needed. As
> it is today I copy code from othe unit tests and hope that it works, really
> without having full control of what I'm doing, which isn't a situation that
> I'm completely happy with.
>
> I would be willing to put down some of my free time on this if I can get
> help from somebody than understands unit testing with Zope better than me.
The first rule is to write code that depends as little as possible on
Zope. :-) Seriously, it's much easier to test code that has minimal
dependencies. If you compare the ZODB tests, the TAL tests, and the
RestrictedPython tests, you'll probably find little in common besides
use of the "unittest" module. That's because they really don't depend
on Zope, only Python.
Now, you might be referring to *functional* tests. Functional tests
check the behavior of a series of components and their interactions. We
don't have a good functional testing framework yet, but Tres has been
working on something in this area. The "Puffin" project has also been
proposed as a solution (since most functional tests of Zope code can
simply use HTTP requests).
Shane