Goal : Write More efficient unit tests for the converters
Current situation
Actually the basic unit test are working as following :
- Input a string
- Process the string with the converter
- And compare the result to an expected result
This is not the best solution, because string can be different, even if the result is fine (just a change in the order or the attribute can broke the test).
General Solution
Instead of comparing strings, we should compare XML, not strings.
So the algorithm will be following
- Input a string
- Process the string with the converter
- Convert the result to an XML object
- Compare it to an expected XML Object.
To avoid to rewrite all the test, and to let the programmer write easy string for the tests, the best will be to also convert the expected string in to XML object, instead of directly write the XML object.
Another approach would e to give just the list of expected node in the resulting XML object.
Possible technical solution
Some thoughts about XML comparison on stackoverflow : http://stackoverflow.com/questions/321795/comparing-xml-in-a-unit-test-in-python
- Using XPATH
Check the different algorithm to compare two XML files.