```{index} single: Test2::Event::Generic ``` # Test2::Event::Generic Generic event type. ## DESCRIPTION This is a generic event that lets you customize all fields in the event API. This is useful if you have need for a custom event that does not make sense as a published reusable event subclass. ## SYNOPSIS ```perl use Test2::API qw/context/; sub send_custom_fail { my $ctx = shift; $ctx->send_event('Generic', causes_fail => 1, summary => 'The sky is falling'); $ctx->release; } send_custom_fail(); ``` ## METHODS - $e->facet\_data($data) - $data = $e->facet\_data Get or set the facet data (see [Test2::Event](../Event.md)). If no facet\_data is set then `Test2::Event->facet_data` will be called to produce facets from the other data. - $e->callback($hub) Call the custom callback if one is set, otherwise this does nothing. - $e->set\_callback(sub { ... }) Set the custom callback. The custom callback must be a coderef. The first argument to your callback will be the event itself, the second will be the [Test2::Hub](../Hub.md) that is using the callback. - $bool = $e->causes\_fail - $e->set\_causes\_fail($bool) Get/Set the `causes_fail` attribute. This defaults to `0`. - $bool = $e->diagnostics - $e->set\_diagnostics($bool) Get/Set the `diagnostics` attribute. This defaults to `0`. - $bool\_or\_undef = $e->global - @bool\_or\_empty = $e->global - $e->set\_global($bool\_or\_undef) Get/Set the `diagnostics` attribute. This defaults to an empty list which is undef in scalar context. - $bool = $e->increments\_count - $e->set\_increments\_count($bool) Get/Set the `increments_count` attribute. This defaults to `0`. - $bool = $e->no\_display - $e->set\_no\_display($bool) Get/Set the `no_display` attribute. This defaults to `0`. - @plan = $e->sets\_plan Get the plan if this event sets one. The plan is a list of up to 3 items: `($count, $directive, $reason)`. `$count` must be defined, the others may be undef, or may not exist at all. - $e->set\_sets\_plan(\\@plan) Set the plan. You must pass in an arrayref with up to 3 elements. - $summary = $e->summary - $e->set\_summary($summary\_or\_undef) Get/Set the summary. This will default to the event package `'Test2::Event::Generic'`. You can set it to any value. Setting this to `undef` will reset it to the default. - $int\_or\_undef = $e->terminate - @int\_or\_empty = $e->terminate - $e->set\_terminate($int\_or\_undef) This will get/set the `terminate` attribute. This defaults to undef in scalar context, or an empty list in list context. Setting this to undef will clear it completely. This must be set to a positive integer (0 or larger). ## SOURCE The source code repository for Test2 can be found at [https://github.com/Test-More/test-more/](https://github.com/Test-More/test-more/). ## MAINTAINERS - Chad Granum ## AUTHORS - Chad Granum ## COPYRIGHT Copyright Chad Granum . This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See [https://dev.perl.org/licenses/](https://dev.perl.org/licenses/)