Open happy-barney opened 5 years ago
The first point is interesting. I suspect we could make something work, but perhaps not quite in the form that you have suggested.
I wonder whether something like
test_coverage(sub { ... }, statement => 0.9, branch => 0.8)
would work?
The second point is planned, and partly implemented. The Sort report, such as it is, makes use of this functionality.
Intended usage: there is a package providing REST resource with methods like GET
, POST
.
Tests in project are organized by public api, for example REST-resource-POST.t
.
In this case it will be nice to say: this test suite should cover almost 100% of method, let set list_users
.
That may call other methods, but I don't care about those number, can be even 1 path out of 100
so if syntax will be
test_coverage \&My::Package::list_users, ...;
then it will work for me
The tricky part is knowing when to start collecting coverage, and when to stop and see what the values are.
Stopping is pretty easy - it has to be when the function is called. But the starting is harder. That's why my suggestion works - the coverage is over whatever is in the sub.
Let me have a think about it...
hmm, ok, I got it ... so what about
my $coverdb = cover { ... };
test_coverage $coverdb, 'Foo::Bar::baz', statement ...
or
test_coverage { ... },
expect_statement_coverage ('Foo::Bar::baz') > 100,
expect_path_that_died ('Foo::Bar::Support::baz'),
expect_path_that_lived ('Foo::Bar::Support::baz'),
...
It will be nice to have tooling to work with coverage data inside tests.
Expected usage: