On Mon, Oct 13, 2014 at 9:21 AM, Chris Blackwell <
ch...@team193.com> wrote:
> i'm not familiar with how todo tests are reported in perl, so do i have this
> right;
>
> a test can either pass or fail - it can have no other state.
Basically. (not counting tests that do the equivalent of abort() or
have a syntax error)
> but, if a test is marked as todo and fails its not counted as a failure, but
> just as a 'todo' item
Yes.
> if a test thats marked as todo passes, is that then a failure ?
The difference is how the harness running the tests reports it; here's
some simple examples:
$ cat foo.t
use Test::More;
is(1,1,"simple equiv");
done_testing;
$ perl foo.t
ok 1 - simple equiv
1..1
$ echo $?
0
When running a test using just perl, you get only the output for each
test and a test count.
When running it with a testing harness, you get more info:
$ prove -v foo.t
foo.t ..
ok 1 - simple equiv
1..1
ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.01 cusr
0.00 csys = 0.03 CPU)
Result: PASS
$ echo $?
0
Here's what this looks like with a TODO'd test - the test reports as
"not ok", but
$ cat bar.t
use Test::More;
TODO: {
local $TODO = "NYI";
is(1,2,"simple equiv");
}
done_testing;
$ perl bar.t
not ok 1 - simple equiv # TODO NYI
# Failed (TODO) test 'simple equiv'
# at bar.t line 4.
# got: '1'
# expected: '2'
1..1
$ echo $?
0
$ prove -v bar.t
bar.t ..
not ok 1 - simple equiv # TODO NYI
# Failed (TODO) test 'simple equiv'
# at bar.t line 4.
# got: '1'
# expected: '2'
1..1
ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.01 cusr
0.00 csys = 0.03 CPU)
Result: PASS
$ echo $?
0
And finally, with a passing TODO'd test:
$ perl baz.t
ok 1 - simple equiv # TODO NYI
1..1
$ prove -v baz.t
baz.t ..
ok 1 - simple equiv # TODO NYI
1..1
ok
All tests successful.
Test Summary Report
-------------------
baz.t (Wstat: 0 Tests: 1 Failed: 0)
TODO passed: 1
Files=1, Tests=1, 0 wallclock secs ( 0.01 usr 0.00 sys + 0.01 cusr
0.00 csys = 0.02 CPU)
Result: PASS
$ echo $?
0
So, from an automated testing standpoint, a failing TODO test still
fails the individual test, but the harness doesn't report that the
file fails; a passing TODO test isn't a failure either; both the test
and the file passes.
By default, I get additional diagnostic information on a passing TODO
- typically I would see this when running the tests as a developer,
rather than via an automated testing process (though I've done this
both ways)
In the meantime, until the test starts passing, I insure that the code
at least compiles, and I'll have some way of telling when the test
starts working.
Regards.