In all the tutorials I've read for Test::Class
, there seems to be one runner script that loads all of the classes. And I think from the perspective of Test::Harness
this is just one giant test. I don't think it can parallelize the tests inside the runner.
My X problem is that I am trying to factor out superclass behaviors when testing subclasses. Each subclass should have its own subclass test (that can be parallelized), but also exercise behaviors inherited from the superclass. How does one that?
Edit: I found these two posts from 2007 that seem to imply that what I'm asking for is incompatible/not possible. Any update since then?
Test::Class
to support parallelismTest::Class
and Test::Harness
are ideologically exclusive)Test::Class
doesn't support parallelisation on its own. Probably the easiest solution would be to have separate .t
runners for each of your test classes (or for logical groups of test classes), and run using e.g. prove -j9
.
If you really want to run all of the tests in parallel you could write a simple script to auto-generate a .t
file for each test class. You'd lose the performance benefit of running multiple test classes within a single perl interpreter, but the parallelisation might compensate for the additional startup overhead. And I'd argue that no matter how much Test::Class
tries to provide test isolation, it's impossible to guarantee that in Perl. Once you start taking advantage of modifying the symbol table for mocking purposes etc, your tests will start to interfere with each other unless you always get the cleanup right. Running each test in a separate perl interpreter is a better way to provide guaranteed isolation.
To make Test::Class parallel, I had Used the following mechanism. Hope it could help you.
I had made use of the Parallel::ForkManager
module to invoke the tests. But had
parameterized the TEST_METHOD
environment variable, so that the required tests are run
in each thread parallely
This provides a isolation among other tests because, each test is invoked independently, and
the thread process is managed to wait until all the child process are completed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With