Test2::Manual::Tooling::Plugin::TestingDone - Run code when the test file is finished, or when done_testing is called.
This is a way to add behavior to the end of a test file. This code is run either when done_testing() is called, or when the test file has no more run-time code to run.
When triggered by done_testing() this will be run BEFORE the plan is calculated and sent. This means it IS safe to make test assertions in this callback.
package Test2::Plugin::MyPlugin;
use Test2::API qw{test2_add_callback_testing_done};
sub import {
my $class = shift;
test2_add_callback_testing_done(sub {
ok(!$some_global, '$some_global was not set');
print "The test file is done, or done_testing was just called\n"
});
}
1;
This imports the test2_add_callback_testing_done()
callback.