开发者

Testing of data structures and xml in perl

I have a tool that:

1. Converts several data structures to XML. I use XML::Element to convert from data structure to XML.

2. Converts XML to data structures. I use XML::TreeBuilder to convert XML to data structures.

I need to write unit tests for this tool.

1. In order to test conversion of data structures to XML I perform testing of the XML using functions from Test::XML::XPath module. For example - like_xpath function.

2. In order to test conversion of XML to data structures I use function cmp_deeply from Test::Deep.

Is it correct approach of testing data structu开发者_StackOverflow社区res and XML?

Or I missed something?

PS.

It's my first experience of unit tests in perl.


Perhaps I'm being simple-minded, but this seems like a situation where it might be better to test the big picture rather than worrying about the details in between. Here's a schematic example:

my $orig_data_structure = ...

my $xml = data_to_xml($orig_data_structure);
my $new_data_structure = xml_to_data($xml);

my $msg = 'The round trip should leave the data unchanged.';
cmp_deeply($new_data_structure, $orig_data_structure, $msg);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜