Problem
/opt/perl/bin/prove -v -I/opt t/Basket_delivery_estimates.t
t/Basket_GetDeliveryEstimates.t
ok 1 - Pick up the basket ....
[2014-12-12 14:33:52] [christmas_promise_01] [1][2014-12-03 14:33:52] [2014-12-04 14:33:52] [2014-12-03 14:33:52] [2014-12-04 14:33:52]ok 2 - Achievable delivery deadline Shopping.Basket.GetProcessingTimes
ok 3 - no warnings
1..3
Test Summary Report
-------------------
t/Basket_delivery_estimates.t (Wstat: 0 Tests: 2 Failed: 0)
Parse errors: Tests out of sequence. Found (3) but expected (2)
Bad plan. You planned 3 tests but ran 2.
Files=1, Tests=2, 17 wallclock secs ( 0.04 usr 0.01 sys + 6.42 cusr 0.67 csys = 7.14 CPU)
Result: FAIL
Solution
The unit test file contains:
use Test::More qw(no_plan);
so the number of tests will be calculated dynamically as the tests are run. No problem here.
Looking at the output we can see three tests are reported: ok1, ok2 and ok3. However, the final conclusion is:
Bad plan. You planned 3 tests but ran 2
Why, oh why?
The reason is that the TAP parser, processing the test results, actually did not "see" the ok2. TAP, as a protocol, expects the output of the tests in a prescribed format, so it can be parsed to produce test stats. My mistake was, I did not put "\n" or use say, when printing out some debug data. This caused the output ok2 NOT to be at the beginning of the line, where the TAP parser expected it, hence missing result of one test. The parser was aware of the test being run (a test method from Test::More), but could not see the test output - discrepancy. Making sure all test results (ok....) appeared at the beginning of the line fixed the problem.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.