I'm all for making things easier to test, but we may want to be careful
about doing a string to string comparisons between an expected output file
and the serialization.  Whitespace changes, element reordering, or other
subtle syntactical differences could cause the tests to fail when the
semantics haven't changed at all.

So basically, I like this approach so long as the comparison is deeper than
string.equals().

Matt Marum



|------------>
| From:      |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Eric Woods <[email protected]>                                              
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |[email protected]                                                       
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |02/24/2011 10:32 AM                                                          
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Testing XML/ATOM Serialization                                               
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|





Currently, testing the automated serialization from JSON to ATOM/XML is
labor intensive and involves manually parsing XML.  I think it would be
easier to include test fixtures, local text files, which express a given
server response in JSON, XML, and ATOM serializations.  The unit tests can
then compare against these local files to ensure the automated
serialization matches the expected serialization in the test file.

A benefit to this approach (besides making it easier to test) is that the
serialization in the text file can be clearly shown to third parties to
reach consensus on the serialization format, whereas the XML parsing logic
is more difficult to convey ;)  What do you guys think?

- Eric W.

Reply via email to