Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在perl中测试数据结构和xml_Perl_Unit Testing - Fatal编程技术网

在perl中测试数据结构和xml

在perl中测试数据结构和xml,perl,unit-testing,Perl,Unit Testing,我有一个工具: 1。将多个数据结构转换为XML。我使用XML::Element将数据结构转换为XML。 2.将XML转换为数据结构。我使用XML::TreeBuilder将XML转换为数据结构 我需要为此工具编写单元测试。 1.为了测试数据结构到XML的转换,我使用test::XML::XPath模块中的函数执行XML测试。例如-类似于xpath函数。 2.为了测试XML到数据结构的转换,我使用test::Deep中的函数cmp\u deeph 它是测试数据结构和XML的正确方法吗? 还是我错过

我有一个工具:
1。将多个数据结构转换为XML。我使用XML::Element将数据结构转换为XML。
2.将XML转换为数据结构。我使用XML::TreeBuilder将XML转换为数据结构

我需要为此工具编写单元测试。
1.为了测试数据结构到XML的转换,我使用test::XML::XPath模块中的函数执行XML测试。例如-类似于xpath函数。
2.为了测试XML到数据结构的转换,我使用test::Deep中的函数cmp\u deeph

它是测试数据结构和XML的正确方法吗?
还是我错过了什么?
PS.

这是我第一次使用perl进行单元测试。

也许我的想法很简单,但在这种情况下,最好测试全局,而不是担心中间的细节。下面是一个示意图示例:

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);

也许我的想法很简单,但这似乎是一种情况,在这种情况下,最好测试全局,而不是担心中间的细节。下面是一个示意图示例:

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);

在本例中,我们不知道生成了什么XML。是-转换是正确的。但是xml可能是错误的,在这种情况下,我们不知道生成了什么xml。是-转换是正确的。但xml可能是错误的。