Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Question about JUnit Tests

Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm writing some JUnit tests that will use the XPath API to check to see if the node values for all possible nodes are correct in an XML document. Suppose all of these JUnit tests pass. Would it be reasonable to assume that the XML document was formed correctly? Would it be necessary to write another JUnit test that validates the XML document against a schema?
Posts: 1845
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would feel safer with a schema validation than with manual checks.

All the tags might be there, and they might all have valid values. But do your tests cover everything the schema covers? And will the next person to maintain this code be as thorough?

Do the tags have to be in a specific order?
Do you have enumerated types in the schema, and are all the valid values covered?

Presumably when used in the "real" application the messages will be validated against a schema.
So why not subject it to the same treatment in testing?
Catching an error in testing is always better than catching it in production. And if it can be detected by doing something as simple as validating against a schema, why wouldn't you?

Whatever. Here's a tiny ad:
Garden Master Course kickstarter
    Bookmark Topic Watch Topic
  • New Topic