-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathut_suite.tpb
More file actions
112 lines (95 loc) · 3.7 KB
/
ut_suite.tpb
File metadata and controls
112 lines (95 loc) · 3.7 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
create or replace type body ut_suite as
/*
utPLSQL - Version 3
Copyright 2016 - 2021 utPLSQL Project
Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
constructor function ut_suite (
self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2, a_line_no integer,
a_tags ut_varchar2_rows := null
) return self as result is
begin
self.self_type := $$plsql_unit;
self.init(a_object_owner, a_object_name, a_object_name, a_line_no);
self.items := ut_suite_items();
before_all_list := ut_executables();
after_all_list := ut_executables();
self.tags := coalesce(a_tags,ut_varchar2_rows());
return;
end;
overriding member function do_execute(self in out nocopy ut_suite) return boolean is
l_suite_savepoint varchar2(30);
l_no_errors boolean;
procedure propagate_error(a_error_stack_trace varchar2) is
begin
for i in 1..self.items.count loop
self.items(i).mark_as_errored(a_error_stack_trace);
end loop;
end;
begin
ut_utils.debug_log('ut_suite.execute');
if self.get_disabled_flag() then
self.mark_as_skipped(a_skip_reason => self.disabled_reason);
else
self.start_time := current_timestamp;
ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self);
l_suite_savepoint := self.create_savepoint_if_needed();
--includes listener calls for before and after actions
l_no_errors := true;
for i in 1 .. self.before_all_list.count loop
l_no_errors := self.before_all_list(i).do_execute(self);
if not l_no_errors then
propagate_error(self.before_all_list(i).get_error_stack_trace());
exit;
end if;
end loop;
if l_no_errors then
for i in 1 .. self.items.count loop
self.items(i).do_execute();
end loop;
end if;
for i in 1 .. after_all_list.count loop
l_no_errors := self.after_all_list(i).do_execute(self);
if not l_no_errors then
self.put_warning(self.after_all_list(i).get_error_stack_trace());
end if;
end loop;
self.rollback_to_savepoint(l_suite_savepoint);
self.calc_execution_result();
self.end_time := current_timestamp;
ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self);
end if;
return l_no_errors;
end;
overriding member function get_error_stack_traces(self ut_suite) return ut_varchar2_list is
l_stack_traces ut_varchar2_list := ut_varchar2_list();
begin
for i in 1 .. before_all_list.count loop
ut_utils.append_to_list(l_stack_traces, self.before_all_list(i).get_error_stack_trace());
end loop;
for i in 1 .. after_all_list.count loop
ut_utils.append_to_list(l_stack_traces, self.after_all_list(i).get_error_stack_trace());
end loop;
return l_stack_traces;
end;
overriding member function get_serveroutputs return clob is
l_outputs clob;
begin
for i in 1 .. before_all_list.count loop
ut_utils.append_to_clob(l_outputs, self.before_all_list(i).serveroutput);
end loop;
for i in 1 .. after_all_list.count loop
ut_utils.append_to_clob(l_outputs, self.after_all_list(i).serveroutput);
end loop;
return l_outputs;
end;
end;
/