• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Test Case for XML

 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to write test cases for XML parsers.

I have an XML file, i parse it and store it in database. A tag may or may not be present, depending on that I may or may not update that particular field. How to write test cases in such scenarios. I mean documenting not automating through any framework.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34074
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You aren't testing random scenarios. You supply the XML file with your test. You know what it contains. Which means you have two XML files and two scenarios documented.
 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne. What I mean is XMLs are prone to be recursive. I am not sure of how many tags one-in-one may be there, how do we document such a thing into something definite?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34074
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I understand. It's a bit like testing a loop. To be really thorough: you test zero, one, a number in the middle, the max and one over the max.

With XML, you test the element not there at all, one of the element and two or more of the element. Maybe add 10 (a bunch) of the element as well. The idea is to be representative not exhaustive.
 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote: The idea is to be representative not exhaustive.


Makes sense. Thanks!
 
Gopi Chella
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Otherwise you can validate that xml against a XSD.
 
saravanan kanda swamy
Ranch Hand
Posts: 33
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic