[BioRuby] Testing complex nexml output.

Anurag Priyam anurag08priyam at gmail.com
Mon Jun 28 09:52:32 UTC 2010


I am finding it a little difficult testing the nexml serializer.

Any nexml object say otu, is serialized by a function call of the type
NeXML::Writer#serialize_otu, which returns a XML::Node object. A raw nexml
representation can be obtained by calling to_s on the return value. These
nodes are added to the document root and then saved to a file by calling
XML::Document#save.

Now, when it come to testing comparing nexml string does not make sense
because the test is rendered invalid even because of different ordering of
the attributes of a node and newline issues. What I am doing is to
initialize to XML::Node: one from a test fiile and one that i generate by
serialize_otu function and then compare for the equality of these xml nodes
attribute by attribute and child by child. An example here:

http://github.com/yeban/bioruby/blob/writer/test/unit/bio/db/nexml/tc_writer.rb#L166

However lack of a proper XML::Node#eql? is making things a little difficult
for me. See:

http://github.com/yeban/bioruby/blob/writer/test/unit/bio/db/nexml/tc_writer.rb#L222

An obvious solution is to myself define an eql? method in Bio::Node. But, am
I going in the right direction when it comes to testing xml output.

-- 
Anurag Priyam,
2nd Year Undergraduate,
Department of Mechanical Engineering,
IIT Kharagpur.
+91-9775550642



More information about the BioRuby mailing list