Skip Menu |

This queue is for tickets about the Test-Class CPAN distribution.

Report information
The Basics
Id: 123142
Status: new
Priority: 0/
Queue: Test-Class

People
Owner: Nobody in particular
Requestors: tschoening [...] am-soft.de
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.50
Fixed in: (no value)



Subject: expected_tests doesn't strictly correspond to runtests
expected_tests is documented to correspond to the behaviour of runtests: Show quoted text
> Returns the total number of tests that runtests() will run on the specified class/object.
Which makes sense, but isn't the case currently because of different implementation. While calling __PACKAGE__->runtests() executes 31 tests in my case currently, the same call with expected_tests always return 0. The reason is that I have one base class for all my tests currently which doesn't contain any tests itself, but only provides infrastructure, e.g. to read some files and such. As per documentation I can execute runtests on that base class and all tests of all derived subclasses are executed. But if expected_tests of that class is called, the return value wrongly is 0, because derived classes are not taken into account automatically. One possible workaround is to call _test_classes, which is used by runtests, and forward that result to expected_tests manually. package Backend::Tests::Base; use strict; use warnings; use base 'Test::Class'; INIT { my @testClasses = __PACKAGE__->_test_classes(); #pop(@testClasses); use Data::Dumper; warn(Dumper(\@testClasses)); warn(__PACKAGE__->expected_tests(@testClasses)); # die('No tests to execute found.') unless (__PACKAGE__->expected_tests() > 0); Test::Class->runtests(); #warn(__PACKAGE__->expected_tests()); }