I want to write a test for method which is going to extract part of an XML file. The input for this is an array of objects which I generate by parsing a CSV file and creating an object for each line.
I'm not clear on what "the input for this" means. Do you mean that you're providing the method under test with a simulated parse?
Would something like the following work?
That is, provide the raw XML in-line with the test, and also include the expected Data::Dumper output. Tests like this have the benefit of being fairly transparent, even if setting up $foo means creating several objects.# ... setup $foo my $xml = <<XML; <?xml version="1.0" encoding="utf-8"?> <stuff> ... </stuff> XML my $out = $foo->method_under_test($xml); ok ( Data::Dumper::Dumper($out), <<EXPECTED ); $VAR1 = { ... }; EXPECTED
In reply to Re: Testing with non-trivial input
by dws
in thread Testing with non-trivial input
by loris
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |