forked from utPLSQL/utPLSQL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathut_testcase.pkb
187 lines (169 loc) · 5.21 KB
/
ut_testcase.pkb
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */
CREATE OR REPLACE PACKAGE BODY uttestcase
IS
/************************************************************************
GNU General Public License for utPLSQL
Copyright (C) 2000-2003
Steven Feuerstein and the utPLSQL Project
(steven@stevenfeuerstein.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (see license.txt); if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
************************************************************************
$Log$
Revision 1.5 2004/11/23 14:56:48 chrisrimmer
Moved dbms_pipe code into its own package. Also changed some preprocessor flags
Revision 1.4 2004/11/16 09:46:49 chrisrimmer
Changed to new version detection system.
Revision 1.3 2004/07/14 17:01:57 chrisrimmer
Added first version of pluggable reporter packages
Revision 1.2 2003/07/01 19:36:47 chrisrimmer
Added Standard Headers
************************************************************************/
FUNCTION name_from_id (id_in IN ut_testcase.id%TYPE)
RETURN ut_testcase.name%TYPE
IS
retval ut_testcase.name%TYPE;
BEGIN
SELECT name
INTO retval
FROM ut_testcase
WHERE id = id_in;
RETURN retval;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
RETURN NULL;
END;
FUNCTION id_from_name (name_in IN ut_testcase.name%TYPE)
RETURN ut_testcase.id%TYPE
IS
retval ut_testcase.id%TYPE;
BEGIN
SELECT name
INTO retval
FROM ut_testcase
WHERE name = UPPER (name_in);
RETURN retval;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
RETURN NULL;
END;
PROCEDURE ADD (
test_in IN INTEGER,
testcase_in IN VARCHAR2,
desc_in IN VARCHAR2 := NULL,
seq_in IN PLS_INTEGER := NULL
)
IS
&start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1
v_id ut_testcase.id%TYPE;
BEGIN
&start_ge_8_1 v_id := utplsql.seqval ('ut_testcase'); &end_ge_8_1
&start_lt_8_1 SELECT ut_testcase_seq.NEXTVAL INTO v_id FROM dual; &end_lt_8_1
INSERT INTO ut_testcase
(id, test_id, name, description,
seq)
VALUES (v_id, test_in, UPPER (testcase_in), desc_in,
NVL (seq_in, 1));
&start_ge_8_1 COMMIT; &end_ge_8_1
EXCEPTION
WHEN OTHERS
THEN
utreport.pl ( 'Add test error: '
|| SQLERRM);
&start_ge_8_1 ROLLBACK; &end_ge_8_1
RAISE;
END;
PROCEDURE ADD (
test_in IN VARCHAR2,
testcase_in IN VARCHAR2,
desc_in IN VARCHAR2 := NULL,
seq_in IN PLS_INTEGER := NULL
)
IS
BEGIN
ADD (uttest.id_from_name (test_in), testcase_in, desc_in, seq_in);
END;
PROCEDURE rem (test_in IN INTEGER, testcase_in IN VARCHAR2)
IS
&start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1
BEGIN
DELETE FROM ut_testcase
WHERE test_id = test_in
AND name LIKE UPPER (testcase_in);
&start_ge_8_1 COMMIT; &end_ge_8_1
EXCEPTION
WHEN OTHERS
THEN
utreport.pl ( 'Remove test error: '
|| SQLERRM);
&start_ge_8_1 ROLLBACK; &end_ge_8_1
RAISE;
END;
PROCEDURE rem (test_in IN VARCHAR2, testcase_in IN VARCHAR2)
IS
BEGIN
rem (uttest.id_from_name (test_in), testcase_in);
END;
PROCEDURE upd (
test_in IN INTEGER,
testcase_in IN VARCHAR2,
start_in DATE,
end_in DATE,
successful_in BOOLEAN
)
IS
&start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1
v_failure PLS_INTEGER := 0;
BEGIN
IF NOT successful_in
THEN
v_failure := 1;
END IF;
UPDATE ut_testcase
SET last_start = start_in,
last_end = end_in,
executions = executions
+ 1,
failures = failures
+ v_failure
WHERE test_id = test_in
AND name = UPPER (testcase_in);
&start_ge_8_1 COMMIT; &end_ge_8_1
EXCEPTION
WHEN OTHERS
THEN
utreport.pl ( 'Update test error: '
|| SQLERRM);
&start_ge_8_1 ROLLBACK; &end_ge_8_1
RAISE;
END;
PROCEDURE upd (
test_in IN VARCHAR2,
testcase_in IN VARCHAR2,
start_in DATE,
end_in DATE,
successful_in BOOLEAN
)
IS
BEGIN
upd (
uttest.id_from_name (test_in),
testcase_in,
start_in,
end_in,
successful_in
);
END;
END uttestcase;
/