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: Fwd: [xml-dev] Not using mixed content? Then don't use XML

On 10 April 2013 06:23, Rick Jelliffe <rjelliffe@allette.com.au> wrote:
> Ghost? Boo!
> I have four other angles:
> 1) Test driven development.   Before=as=so-soon-after-that-noone-notices
> you make some software, you make a test for it.  If the document has a fixed
> structure, you can test by instances. If the document is semi-structured or
> recursive, your test specification has to allow those kinds of structures
> too: and for XML such a specification is called a schema.

Using a schema here can only get you so far.... it wont catch
hardcoded elements or (yet again) the business rules (unless they are
in the schema)

You need an additional layer that tests by pulling the values out from
the input (or wherever the values in the result are taken from) and
comparing them to the result.  My tests are along the lines of:

String someValue = runQueryOnInput("/some/path/to/val/string(.)");

String valueInResult = runQueryOnOutput("/result/path/to/val/string(.)");

assertEquals(someValue, valueInResult);

...eg it uses xquery to select a value from the input xml, and again
to select a value from the result, then does the assert.   (I have
simple test framework I wrote that allows the tests to be simple like

For business rules that only apply to the result such as "if nnn is
true then every yyy must be false" you can do:

assertTrue(Boolean.valueOf(runQueryOnOutput("if (nnn = 'true') then
not(yyy = 'true') else true()")

...or whatever you test you can conjure up in xquery.

So while validating the result is essential, it's not always
sufficient on its own.

Andrew Welch

[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