in reply to Testing with non-trivial input
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Testing with non-trivial input
by loris (Hermit) on Oct 12, 2005 at 09:35 UTC | |
by dws (Chancellor) on Oct 12, 2005 at 18:11 UTC |