You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
expected_tests is documented to correspond to the behaviour of runtests:
> 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());
}
expected_tests is documented to correspond to the behaviour of runtests:
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.
Original: https://rt.cpan.org/Ticket/Display.html?id=123142
The text was updated successfully, but these errors were encountered: