File Coverage

blib/lib/Test/Run/Plugin/BreakOnFailure.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 2 100.0
condition 2 3 66.6
subroutine 6 6 100.0
pod n/a
total 30 31 96.7


line stmt bran cond sub pod time code
1             package Test::Run::Plugin::BreakOnFailure;
2              
3 2     2   1333394 use warnings;
  2         14  
  2         94  
4 2     2   14 use strict;
  2         4  
  2         46  
5              
6 2     2   56 use 5.008;
  2         7  
7              
8 2     2   534 use MRO::Compat;
  2         1733  
  2         36  
9              
10 2     2   662 use Moose;
  2         483836  
  2         14  
11              
12             =head1 NAME
13              
14             Test::Run::Plugin::BreakOnFailure - stop processing the entire test suite
15             upon the first failure.
16              
17             =head1 VERSION
18              
19             Version 0.0.6
20              
21             =cut
22              
23             our $VERSION = '0.0.6';
24              
25             extends('Test::Run::Base');
26              
27             has 'should_break_on_failure' => (isa => "Bool", is => "rw",);
28              
29             =head1 SYNOPSIS
30              
31             package MyTestRun;
32              
33             use Moose
34              
35             extends(qw(Test::Run::Plugin::BreakOnFailure Test::Run::Obj);
36              
37             =head1 FUNCTIONS
38              
39             =head2 $self->should_break_on_failure()
40              
41             A boolean flag that determines if the test suite should break after the
42             first failing test.
43              
44             =cut
45              
46             sub _run_all_tests_loop
47             {
48 2     2   141194 my $self = shift;
49              
50             TEST_FILES_LOOP:
51 2         6 foreach my $test_file_path (@{$self->test_files()})
  2         51  
52             {
53 3         43 $self->_run_single_test({ test_file => $test_file_path});
54              
55 3 100 66     559564 if ($self->should_break_on_failure()
56             && (!$self->last_test_results->passing())
57             )
58             {
59 1         62 last TEST_FILES_LOOP;
60             }
61             }
62             }
63              
64             =head1 AUTHOR
65              
66             Shlomi Fish, L<http://www.shlomifish.org/> .
67              
68             =head1 SUPPORT
69              
70             You can find documentation for this module with the perldoc command.
71              
72             perldoc Test::Run::Plugin::BreakOnFailure
73              
74             You can also look for information at:
75              
76             =over 4
77              
78             =item * CPAN Ratings
79              
80             L<http://cpanratings.perl.org/d/Test::Run::Plugin::BreakOnFailure>
81              
82             =item * RT: CPAN's request tracker
83              
84             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test::Run::Plugin::BreakOnFailure>
85              
86             =item * MetaCPAN
87              
88             L<https://metacpan.org/release/Test-Run-Plugin-BreakOnFailure>
89              
90             =back
91              
92             =head1 ACKNOWLEDGEMENTS
93              
94             I came up with the idea for this plugin for use for working for my work
95             for Reask ( L<http://reask.com/> ).
96              
97             =head1 SEE ALSO
98              
99             L<Test::Run>, L<Test::Run::CmdLine>, L<TAP::Parser>
100              
101             =head1 COPYRIGHT & LICENSE
102              
103             Copyright 2010 Shlomi Fish.
104              
105             This program is distributed under the MIT (Expat) License:
106             L<http://www.opensource.org/licenses/mit-license.php>
107              
108             Permission is hereby granted, free of charge, to any person
109             obtaining a copy of this software and associated documentation
110             files (the "Software"), to deal in the Software without
111             restriction, including without limitation the rights to use,
112             copy, modify, merge, publish, distribute, sublicense, and/or sell
113             copies of the Software, and to permit persons to whom the
114             Software is furnished to do so, subject to the following
115             conditions:
116              
117             The above copyright notice and this permission notice shall be
118             included in all copies or substantial portions of the Software.
119              
120             =cut
121              
122             1; # End of Test::Run::Plugin::BreakOnFailure