[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: XML and unit testing
- From: "Thomas B. Passin" <tpassin@home.com>
- To: xml-dev@lists.xml.org
- Date: Wed, 04 Jul 2001 15:02:09 -0400
I'd recommend you look at Martin Fowler's excellent book, "Refactoring -
Improving the Design of Existing Code" (Addison-Wesley). He has a lot of
good material on unit testing, including making objects self-testing by
including test() methods. He does talk about using JUnit.
Basically, you can make a piece of code self-testing, or you can write test
wrappers to exercise it. Either way, you want to make each test
self-checking, so you don't have to pore over printouts (which isn't that
reliable anyway). That means you have to come up with a canonical, correct
result for each test that can in some way be checked automatically. This is
more important, I would say, than which specific test harness you use and
exactly how it works.
There is a Python PyUnit, too. I would imagine it would work with Jython as
well (don't know that for a fact, though). That might make it quicker to
set up a test harness.
That DeltaXML tool (http://www.deltaxml.com) that was just announced on the
list might be useful for comparing two pieces of xml. You could run it from
the command line or from java.
Cheers,
Tom P
[Simon St.Laurent]
> I've been considering a unit testing approach for my Regular
> Fragmentations processor [1], trying to figure out what kinds of unit
> testing make sense for a SAX filter [2]. I've looked at things like
> JUnit [3], JXUnit [4], XSLTUnit[5], and XMLUnit[6], and I think I'm now
> more confused than when I started.
>
> In testing a filter, I need to be able to test component pieces, some of
> which are plain old objects and some of which are representations of
> those objects as SAX events and/or XML. I've had a number of cases
> involving shallow copying (finally fixed) where the objects looked great
> at the time of their creation but morphed by the time they reached the
> XML output, so I really need to be able to test these things in a
> variety of situations.
>
> So far, I've been using a set of test cases and my own eyeballs. It's
> worked pretty well as far as figuring out high-level pass/fail, but does
> very little to help me track down where the pass/fail came from.
>
> I doubt I'm the only person dealing with these kinds of issues on
> xml-dev, but I still wonder if anyone's really explored how unit testing
> and XML fit together. Validation is something that comes naturally to
> XML, but it's a different kind of testing than the finer-grained object
> unit testing approach I'm looking for.
>