Test2::Manual::Tooling::Plugin::ToolCompletes(3pm) Perl Programmers Reference Guide Test2::Manual::Tooling::Plugin::ToolCompletes(3pm)

# [NAME](#NAME)

Test2::Manual::Tooling::Plugin::ToolCompletes - How to add behaviors that occur when a tool completes work.

# [DESCRIPTION](#DESCRIPTION)

This tutorial helps you understand how to add behaviors that occur when a tool is done with its work. All tools need to acquire and then release a context, for this tutorial we make use of the release hooks that are called every time a tool releases the context object.

# [COMPLETE CODE UP FRONT](#COMPLETE_CODE_UP_FRONT)

```
    package Test2::Plugin::MyPlugin;
    use Test2::API qw{test2_add_callback_context_release};
    sub import {
        my $class = shift;
        test2_add_callback_context_release(sub {
            my $ctx_ref = shift;
            print "Context was released\n";
        });
    }
    1;
```

# [LINE BY LINE](#LINE_BY_LINE)

[use Test2::API qw{test2\_add\_callback\_context\_release};](#use)

This imports the test2\_add\_callback\_context\_release() callback.

[test2\_add\_callback\_context\_release(sub { ... })](#test2_add_callback_context_release%28sub)

[my $ctx\_ref = shift](#my)

The coderefs for **test2\_add\_callback\_context\_release()** will receive exactly 1 argument, the context being released.

[print "Context was released\\n"](#print)

Print a notification whenever the context is released.

# [SEE ALSO](#SEE_ALSO)

Test2::Manual - Primary index of the manual.

# [SOURCE](#SOURCE)

The source code repository for Test2-Manual can be found at *https://github.com/Test-More/test-more/*.

# [MAINTAINERS](#MAINTAINERS)

[Chad Granum &lt;exodist@cpan.org&gt;](#Chad)

# [AUTHORS](#AUTHORS)

[Chad Granum &lt;exodist@cpan.org&gt;](#Chad~2)

# [COPYRIGHT](#COPYRIGHT)

Copyright Chad Granum &lt;exodist@cpan.org&gt;.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See *http://dev.perl.org/licenses/*

2026-08-31 perl v5.44.0

---

Document: Test2::Manual::Tooling::Plugin::ToolCompletes(3pm) from perl 5.44.0-r1 (Chainguard OS)
Source: https://github.com/Perl/perl5.git
