XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Testing XML don't use xUnit

We certainly make great use of XPath and use XMLUnit. I don't really consider the unit tests to be 'brittle' because tests fail when the structure, that's what I expect to happen in most cases. As per the *other* hot thread on-going, it also somewhat depends on the volatility or the message structures than you use. As Michael said, if your dealing with interfaces, then often a low rate of churn is preferred.

Of course it also all depends on how you write the XPath itself. If there are parts of the structure which I want to skip past then I might very write the XPath to do exactly that, as Mike says, focusing attention on the specific item of fragment that I am interested in. As an example, in some of our tests a exception response structure from a application can contain many nested levels of <RecoverableException> information which is akin to a stack trace. At the bottom of that structure there might be an element called <UserException> and if thats what I'm writing a test for, my XPath may look something like //UserException/blah. Whats wrong with that ?

> and work hard to make unit tests depend only on the component being tested

Yep, eliminating external dependencies is something that I subscribe to.

> IMHO, this encourages a culture of "fix it by randomly mutating the code, and assuming you have it right when the
> unit tests pass", which is downright scary.

Indeed, but that's a different problem than the one being discussed. IMHO that's about making sure that your tests are a demonstration of the business requirements and not a demonstration that some code does something successfully.



On 10 April 2013 17:03, John Cowan <johnwcowan@gmail.com> wrote:
On Wed, Apr 10, 2013 at 10:27 AM, Michael Kay <mike@saxonica.com> wrote:
 
I'm completely bemused. I thought Schematron assertions, like XMLUnit assertions, were both XPath. Why is one better than the other?

According to reports in other messages in this thread, because XMLUnit has no way of setting the context node, so all XPaths must be absolute.  (I don't know this of my own knowledge, I'm just reporting.) 

Unit testing has always been exposed to the problem that when things change, tests break.

Unit-test advocates consider this to be a Good Thing, and work hard to make unit tests depend only on the component being tested, all else being represented by mock objects whose behavior is stable because they don't have to really work.  Where things get Very Bad is when developers equate "all unit tests still pass" with "the application still works".  IMHO, this encourages a culture of "fix it by randomly mutating the code, and assuming you have it right when the unit tests pass", which is downright scary.  Programming is about understanding, not about code-whacking.

--
GMail doesn't have rotating .sigs, but you can see mine at http://www.ccil.org/~cowan/signatures



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS