|
testing joys So, I've been working on a basic compound document system for Zope for a couple of weeks now, based on ideas from OpenDoc coupled with ideas from previous Zope implementations (both at Cue Media and in my past life at Zope Corp). The work's been going slowly. Part of this is because the project started out as just trying to turn some of our recent consulting work patterns into a stronger starting-point framework for the next. A lot of modules were created and checked in before I completely changed the target design, although not really the target mission. But, as a result, there's a fair bit of code that's being rewritten on the spot all because I didn't want to start a new CVS module.Things are starting to come together now, so a couple of days ago I started a new OmniOutliner 2 outline (the best outliner I've ever used, and so beautiful in Mac OS X) to try to get some good steps down for what I needed to do to get a bare bones compound document running. I'm currently a couple of days overdue from this seemingly simple task. Part of it has been that I've been wrestling with a lot of chicken versus egg questions that deal with starting to get these objects up on the web. Normally, Zope makes this pretty easy. But I'm going through a rather tricky design that brings some Zope 3 ideas down to Zope 2, but without all of Zope 3's new machinery. All I wanted to see though was whether an empty document (which has an empty root) would render an empty string, and whether adding a Text Part to that root with the plain text contents of "Hi There!" would render out a string saying "Hi There!". Finally, today, it hit me - unit tests. Of course. I'm beating myself a little bit for not thinking of this sooner, but since the project is still very young, I'm being forgiving. So I started writing tests, and my first major question (empty document renders an empty string) ran true, after I fixed a couple of bugs. The second question is returning false, and I'm realizing that I have a few other components yet to test. So I'm now writing tests for them (little text handling components) to make sure the error isn't there. It's easy to forget the joys of unit tests, especially in regards to fundamental Zope components. Since there's no UI at this level yet, it's easy to find the different fundamental units of functionality and ensure that they work. Then, when I finally do deal with the chicken/egg questions dealing with how the UI will come together and editors/previewers/renderers will come out of the surrounding universe, at least I won't be chasing unrelated bugs from the core components.
It's the basic story of testing. It's just that it's so easy to forget exactly how nice it is when that body of tests starts growing and one can refactor without fear. |
Navigation
|