Test2::AsyncSubtest - Object representing an async subtest.
Regular subtests have a limited scope, they start, events are generated, then they close and send an Test2::Event::Subtest event. This is a problem if you want the subtest to keep receiving events while other events are also being generated. This class implements subtests that stay open until you decide to close them.
This is mainly useful for tools that start a subtest in one process and then spawn children. In many cases it is nice to let the parent process continue instead of waiting on the children.
use Test2::AsyncSubtest;
my $ast = Test2::AsyncSubtest->new(name => foo);
$ast->run(sub {
ok(1, "Event in parent" );
});
ok(1, "Event outside of subtest");
$ast->run_fork(sub {
ok(1, "Event in child process");
});
...
$ast->finish;
done_testing;
my $ast = Test2::AsyncSubtest->new( ... );
Name of the subtest. This construction argument is required.
Hub to which the final subtest event should be sent. This must be an instance of Test2::Hub or a subclass. If none is specified then the current top hub will be used.
File/Line to which errors should be attributed. This must be an instance of Test2::Util::Trace. If none is specified then the file/line where the constructor was called will be used.
Use this to specify a hub the subtest should use. By default a new hub is generated. This must be an instance of Test2::AsyncSubtest::Hub.
True if the subtest is active. The subtest is active if its hub appears in the global hub stack. This is true when $ast->run(...)
us running.
Get an arrayref of child processes/threads. Numerical items are PIDs, blessed items are threads instances.
Get an arrayref of events that have been sent to the subtests hub.
True if finished()
has already been called.
The hub created for the subtest.