• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about JUnit Tests

 
Ranch Hand
Posts: 226
1
  • 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?
 
Bartender
Posts: 1845
10
  • 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?

 
You firghten me terribly. I would like to go home now. Here, take this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic