examples/patch100132-2

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« examples/patch100132-1 ↑ Summary blib/lib/Test/Unit/Loader.pm »
1 #!/usr/bin/perl -w
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Experimental::Sample;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Test::Unit::Procedural;
Subroutine BEGIN: called CC=1 SCAR=2.6
7  
8 use constant DEBUG => 0;
9  
10 # code to be tested will be somewhere around here
11  
12 # define tests, set_up and tear_down
13  
14 sub test_ok_1 {
15 assert(23 == 23);
16 }
17  
18 sub test_ok_2 {
19 assert(42 == 42);
20 }
21  
22 sub test_ok_3 {
23 my $sample = new Experimental::Sample();
24 $sample->name( 'Joe' );
25 assert( 'Joe' eq $sample->name() );
26 }
27  
28 sub set_up {
29 print "hello world\n" if DEBUG;
30 }
31  
32 sub tear_down {
33 print "leaving world again\n" if DEBUG;
34 }
35  
36 # and run them
37  
38 # This will not work, as the test methods were
39 # defined in package main:
40 #
41 # create_suite( 'Experimental::Sample' );
42 # run_suite();
43 #
44 # We need to create the default suite to pick
45 # our test methods up - they just use the
46 # methods in Experimental::Sample ...
47 #
48 # The other way is to define the tests in
49 # package Experimental::Sample itself.
50 # Then we can proceed as indicated above,
51 # but we obviously need to run the suite
52 # we created, not the default suite:
53  
54 sub Experimental::Sample::test_ok_1 {
55 assert(23 == 23);
56 }
57  
58 sub Experimental::Sample::test_ok_2 {
59 assert(42 == 42);
60 }
61  
62 sub Experimental::Sample::test_ok_3 {
63 my $sample = new Experimental::Sample();
64 $sample->name( 'Joe' );
65 assert( 'Joe' eq $sample->name() );
66 }
67  
68 create_suite( 'Experimental::Sample' );
69 run_suite( 'Experimental::Sample' );
« examples/patch100132-1 ↑ Summary blib/lib/Test/Unit/Loader.pm »