1 package Test2::Event::Subtest;
5 our $VERSION = '1.302133';
7 BEGIN { require Test2::Event::Ok; our @ISA = qw(Test2::Event::Ok) }
8 use Test2::Util::HashBase qw{subevents buffered subtest_id subtest_uuid};
13 $self->{+SUBEVENTS} ||= [];
14 if ($self->{+EFFECTIVE_PASS}) {
15 $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}};
20 no warnings 'redefine';
26 if ($self->{+EFFECTIVE_PASS}) {
27 $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @subevents;
30 $self->{+SUBEVENTS} = \@subevents;
33 sub set_effective_pass {
38 $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}};
40 elsif ($self->{+EFFECTIVE_PASS} && !$pass) {
41 for my $s (grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}}) {
42 $_->set_effective_pass(0) unless $s->can('todo') && defined $s->todo;
46 $self->{+EFFECTIVE_PASS} = $pass;
53 my $name = $self->{+NAME} || "Nameless Subtest";
55 my $todo = $self->{+TODO};
57 $name .= " (TODO: $todo)";
59 elsif (defined $todo) {
69 my $out = $self->SUPER::facet_data();
72 hid => $self->subtest_id,
73 children => [map {$_->facet_data} @{$self->{+SUBEVENTS}}],
74 buffered => $self->{+BUFFERED},
84 $am = {%$am} if ref($am) ne 'ARRAY';
85 $am = Test2::EventFacet::Amnesty->new($am);
87 push @{$self->{+AMNESTY}} => $am;
89 for my $e (@{$self->{+SUBEVENTS}}) {
90 $e->add_amnesty($am->clone(inherited => 1));
106 Test2::Event::Subtest - Event for subtest types
110 This class represents a subtest. This class is a subclass of
115 This class inherits from L<Test2::Event::Ok>.
119 =item $arrayref = $e->subevents
121 Returns the arrayref containing all the events from the subtest
123 =item $bool = $e->buffered
125 True if the subtest is buffered, that is all subevents render at once. If this
126 is false it means all subevents render as they are produced.
132 The source code repository for Test2 can be found at
133 F<http://github.com/Test-More/test-more/>.
139 =item Chad Granum E<lt>exodist@cpan.orgE<gt>
147 =item Chad Granum E<lt>exodist@cpan.orgE<gt>
153 Copyright 2018 Chad Granum E<lt>exodist@cpan.orgE<gt>.
155 This program is free software; you can redistribute it and/or
156 modify it under the same terms as Perl itself.
158 See F<http://dev.perl.org/licenses/>