Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4f0f712

Browse files
committed
merged small fixes from PR #4
1 parent f50a4e9 commit 4f0f712

17 files changed

Lines changed: 72 additions & 85 deletions

examples/RunExampleComplexSuiteWithCustomDBMSOutputReporter.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--Shows how to create a test suite with the default reporter which is dbms_output
22
--No tables are used for this.
33
--Suite Management packages are when developed will make this easier.
4-
Clear Screen
4+
--Clear Screen
55
Set Serveroutput On Size Unlimited format truncated
66
set echo off
77
--install the example unit test packages
@@ -43,4 +43,6 @@ begin
4343
end;
4444
/
4545

46-
drop type ut_custom_reporter;
46+
--drop type ut_custom_reporter;
47+
drop package ut_exampletest;
48+
drop package ut_exampletest2;

examples/RunExampleTestSuite.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--Shows how to create a test suite in code and call the test runner.
22
--No tables are used for this.
33
--Suite Management packages are when developed will make this easier.
4-
Clear Screen
4+
--Clear Screen
55
Set Serveroutput On Size Unlimited format truncated
66
set echo off
77
--install the example unit test packages
@@ -47,3 +47,6 @@ begin
4747
dbms_output.put_line('---------------------------------------------------');
4848
end;
4949
/
50+
51+
drop package ut_exampletest;
52+
drop package ut_exampletest2;

examples/RunExampleTestSuiteWithCustomDBMSOutputReporter.sql

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
--Shows how to create a test suite with the default reporter which is dbms_output
22
--No tables are used for this.
33
--Suite Management packages are when developed will make this easier.
4-
Clear Screen
5-
Set Serveroutput On Size Unlimited format truncated --http://stackoverflow.com/questions/2584492/how-to-prevent-dbms-output-put-line-from-trimming-leading-whitespace
4+
--Clear Screen
5+
--http://stackoverflow.com/questions/2584492/how-to-prevent-dbms-output-put-line-from-trimming-leading-whitespace
6+
Set Serveroutput On Size Unlimited format truncated
67
set echo off
78
--install the example unit test packages
89
@@ut_exampletest.pks
@@ -40,4 +41,7 @@ end;
4041
/
4142

4243

43-
drop type ut_custom_reporter;
44+
--FIXME this drop is causing issues when executing script several times within single session
45+
--drop type ut_custom_reporter;
46+
drop package ut_exampletest;
47+
drop package ut_exampletest2;

examples/RunExampleTestSuiteWithDBMSOutputReporter.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--Shows how to create a test suite with the default reporter which is dbms_output
22
--No tables are used for this.
33
--Suite Management packages are when developed will make this easier.
4-
Clear Screen
4+
--Clear Screen
55
Set Serveroutput On Size Unlimited format truncated
66
set echo off
77
--install the example unit test packages
@@ -34,3 +34,6 @@ begin
3434
suite.execute(ut_dbms_output_suite_reporter);
3535
end;
3636
/
37+
38+
drop package ut_exampletest;
39+
drop package ut_exampletest2;

examples/RunExampleTestThroughBaseClass.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--This shows how the interna test engine works to test a single package.
22
--No tables are used for this and exceptions are handled better.
3-
Clear Screen
3+
--Clear Screen
44
Set Serveroutput On Size Unlimited format truncated
55
set echo off
66
--install the example unit test packages
@@ -23,3 +23,5 @@ begin
2323
simple_test.execute(reporter);
2424
end;
2525
/
26+
27+
drop package ut_exampletest;

examples/ut_custom_reporter.tpb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ create or replace type body ut_custom_reporter is
2626
lvl := lvl + 1;
2727
end;
2828

29-
overriding member procedure end_suite(self in out nocopy ut_custom_reporter, a_suite_name in varchar2, a_suite_execution_result in ut_execution_result) as
30-
begin
31-
lvl := lvl - 1;
32-
(self as ut_dbms_output_suite_reporter).end_suite(a_suite_name,a_suite_execution_result);
33-
end;
34-
3529
overriding member procedure begin_test(self in out nocopy ut_custom_reporter, a_test_name in varchar2, a_test_call_params in ut_test_call_params) as
3630
begin
3731
(self as ut_dbms_output_suite_reporter).begin_test(a_test_name,a_test_call_params);
@@ -43,6 +37,12 @@ create or replace type body ut_custom_reporter is
4337
lvl := lvl - 1;
4438
(self as ut_dbms_output_suite_reporter).end_test(a_test_name, a_test_call_params, a_execution_result, a_assert_list);
4539
end;
40+
41+
overriding member procedure end_suite(self in out nocopy ut_custom_reporter, a_suite_name in varchar2, a_suite_execution_result in ut_execution_result) as
42+
begin
43+
lvl := lvl - 1;
44+
(self as ut_dbms_output_suite_reporter).end_suite(a_suite_name,a_suite_execution_result);
45+
end;
4646

4747
end;
4848
/

examples/ut_custom_reporter.tps

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ create or replace type ut_custom_reporter under ut_dbms_output_suite_reporter
88
member function tab(self in ut_custom_reporter) return varchar2,
99
overriding member procedure print(msg varchar2),
1010
overriding member procedure begin_suite(self in out nocopy ut_custom_reporter, a_suite_name in varchar2),
11-
overriding member procedure end_suite(self in out nocopy ut_custom_reporter, a_suite_name in varchar2, a_suite_execution_result in ut_execution_result),
1211
overriding member procedure begin_test(self in out nocopy ut_custom_reporter, a_test_name in varchar2, a_test_call_params in ut_test_call_params),
13-
overriding member procedure end_test(self in out nocopy ut_custom_reporter, a_test_name in varchar2, a_test_call_params in ut_test_call_params, a_execution_result in ut_execution_result, a_assert_list in ut_assert_list)
12+
overriding member procedure end_test(self in out nocopy ut_custom_reporter, a_test_name in varchar2, a_test_call_params in ut_test_call_params, a_execution_result in ut_execution_result, a_assert_list in ut_assert_list),
13+
overriding member procedure end_suite(self in out nocopy ut_custom_reporter, a_suite_name in varchar2, a_suite_execution_result in ut_execution_result)
1414
)
1515
not final
1616
/
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
create or replace type ut_reporter_decorator under ut_suite_reporter
22
(
3-
-- Author : PAZZZ
4-
-- Created : 20.07.2016 23:31:07
5-
-- Purpose :
6-
7-
-- Attributes
83
decorated_reporter ut_suite_reporter,
94

10-
-- Member functions and procedures
115
constructor function ut_reporter_decorator(a_decorated_reporter ut_suite_reporter) return self as result,
12-
member procedure init(self in out nocopy ut_reporter_decorator, a_decorated_reporter ut_suite_reporter)
6+
member procedure init(self in out nocopy ut_reporter_decorator, a_decorated_reporter ut_suite_reporter)
137

148
) not final not instantiable
159
/

source/types/ut_test.tpb

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,15 @@ create or replace type body ut_test is
1414

1515
member function is_valid(self in ut_test) return boolean is
1616
begin
17-
if call_params.test_procedure is null then
18-
return false;
19-
end if;
20-
21-
if not ut_metadata.resolvable(call_params.owner_name, call_params.object_name, call_params.test_procedure) then
22-
return false;
23-
end if;
24-
25-
if call_params.setup_procedure is not null and
26-
not ut_metadata.resolvable(call_params.owner_name, call_params.object_name, call_params.setup_procedure) then
27-
return false;
28-
end if;
29-
30-
if call_params.teardown_procedure is not null and
31-
not ut_metadata.resolvable(call_params.owner_name, call_params.object_name, call_params.teardown_procedure) then
32-
return false;
33-
end if;
34-
35-
return true;
17+
return call_params.test_procedure is not null and ut_metadata.resolvable(call_params.owner_name, call_params.object_name, call_params.test_procedure) and (call_params.setup_procedure is null OR ut_metadata.resolvable(call_params.owner_name, call_params.object_name, call_params.setup_procedure)) and (call_params.teardown_procedure is null OR ut_metadata.resolvable(call_params.owner_name, call_params.object_name, call_params.teardown_procedure));
3618
end is_valid;
3719

3820
overriding member procedure execute(self in out nocopy ut_test, a_reporter ut_suite_reporter) is
39-
params_valid boolean;
21+
reporter ut_suite_reporter := a_reporter;
22+
begin
23+
reporter := execute(reporter);
24+
end;
25+
overriding member function execute(self in out nocopy ut_test, a_reporter ut_suite_reporter) return ut_suite_reporter is
4026
reporter ut_suite_reporter := a_reporter;
4127
begin
4228
if reporter is not null then
@@ -49,10 +35,8 @@ create or replace type body ut_test is
4935
$end
5036

5137
self.execution_result := ut_execution_result();
52-
53-
self.call_params.validate_params(params_valid);
5438

55-
if params_valid then
39+
if self.call_params.validate_params() then
5640
self.call_params.setup;
5741
begin
5842
self.call_params.run_test;
@@ -97,6 +81,7 @@ create or replace type body ut_test is
9781
,a_execution_result => self.execution_result
9882
,a_assert_list => self.assert_results);
9983
end if;
84+
return reporter;
10085
end;
10186

10287
overriding member procedure execute(self in out nocopy ut_test) is

source/types/ut_test.tps

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
create or replace type ut_test force under ut_test_object
22
(
33

4-
/*
5-
object_name varchar2(32 char),
6-
test_procedure varchar2(32 char),
7-
owner_name varchar2(32 char),
8-
setup_procedure varchar2(32 char),
9-
teardown_procedure varchar2(32 char),
10-
*/
11-
call_params ut_test_call_params,
4+
call_params ut_test_call_params,
125
assert_results ut_assert_list,
136

147
constructor function ut_test(a_object_name varchar2, a_test_procedure varchar2, a_test_name in varchar2 default null, a_owner_name varchar2 default null, a_setup_procedure varchar2 default null, a_teardown_procedure varchar2 default null)
@@ -17,6 +10,7 @@ create or replace type ut_test force under ut_test_object
1710
member function is_valid(self in ut_test) return boolean,
1811

1912
overriding member procedure execute(self in out nocopy ut_test, a_reporter ut_suite_reporter),
13+
overriding member function execute(self in out nocopy ut_test, a_reporter ut_suite_reporter) return ut_suite_reporter,
2014
overriding member procedure execute(self in out nocopy ut_test)
2115

2216
)

0 commit comments

Comments
 (0)