File: procedural-adding-suites-example.pl

package info (click to toggle)
libtest-unit-perl 0.25-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,400 kB
  • sloc: perl: 4,290; makefile: 5
file content (72 lines) | stat: -rw-r--r-- 1,183 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# --------------------------------------------------
package Foo;

use Test::Unit;

use constant DEBUG => 0;

# code to be tested will be somewhere around here

# define tests, set_up and tear_down

sub test_foo_ok_1 {
	assert(23 == 23);
}

sub test_foo_ok_2 {
	assert(42 == 42);
}

sub set_up {
	print "hello world\n" if DEBUG;
}

sub tear_down {
	print "leaving world again\n" if DEBUG;
}

# --------------------------------------------------
package Bar;

use Test::Unit;

use constant DEBUG => 0;

# code to be tested will be somewhere around here

# define tests, set_up and tear_down

sub test_bar_ok_1 {
	assert(23 == 23);
}

sub test_bar_ok_2 {
	assert(42 == 42);
}

sub set_up {
	print "hello world\n" if DEBUG;
}

sub tear_down {
	print "leaving world again\n" if DEBUG;
}

# --------------------------------------------------
package FooBar;

use Test::Unit;

create_suite();
create_suite("Foo");
create_suite("Bar");

add_suite("Foo"); # add Foo to this package
add_suite("Bar"); # add Bar to this package

print "\n--- Testing FooBar ---\n";
run_suite();

add_suite("Foo", "Bar"); # add Foo to Bar
print "\n--- Testing Bar with Foo added to it ---\n";
run_suite("Bar");