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

Skip to content

Commit e04dba8

Browse files
committed
Merge remote-tracking branch 'remotes/upstream/version3' into feature/runner
2 parents cebe94c + 301f336 commit e04dba8

34 files changed

Lines changed: 501 additions & 258 deletions

build/utplsql_style_check.sql

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
ALTER SESSION SET PLSCOPE_SETTINGS= 'IDENTIFIERS:ALL';
1+
alter session set plscope_settings= 'identifiers:all';
2+
set linesize 300
23

34
--install or comple all code here
45
exec dbms_utility.compile_schema(USER,compile_all => TRUE,reuse_settings => FALSE);
@@ -12,39 +13,44 @@ column errcnt_c noprint new_value errcnt_c
1213

1314
--find parameters that donot begin with A_
1415
prompt parameters should start with A_
15-
select NAME,TYPE,OBJECT_NAME,OBJECT_TYPE,USAGE,LINE,COL , count(*) over() errcnt_a
16-
from user_identifiers
17-
where type like 'FORMAL%' and usage = 'DECLARATION'
18-
and name != 'SELF'
19-
and name not like 'A#_%' escape '#'
20-
order by object_name, object_type, line, col
16+
select name, type, object_name, object_type, usage, line, col, count(*) over() errcnt_a
17+
from user_identifiers
18+
where type like 'FORMAL%' and usage = 'DECLARATION'
19+
and name != 'SELF'
20+
and name not like 'A#_%' escape '#'
21+
order by object_name, object_type, line, col
2122
;
2223

2324
prompt variables should start with L_
2425
--variables start with l_ or g_
25-
select NAME,TYPE,OBJECT_NAME,OBJECT_TYPE,USAGE,LINE,COL , count(*) over() errcnt_l
26-
from user_identifiers
27-
where type like 'VARIABLE' and usage = 'DECLARATION'
28-
and object_type not in ('TYPE')
29-
and (name not like 'L#_%' escape '#'
30-
and name not like 'G#_%' escape '#' --TODO: only valid on package level
31-
)
32-
order by object_name, object_type, line, col
26+
select i.name, i.type, i.object_name, i.object_type, i.usage, i.line, i.col, count(*) over() errcnt_l
27+
from user_identifiers i
28+
join user_identifiers p
29+
on p.object_name = i.object_name and p.object_type = i.object_type
30+
and i.usage_context_id = p.usage_id
31+
where i.type like 'VARIABLE' and i.usage = 'DECLARATION'
32+
and i.object_type not in ('TYPE')
33+
and (i.name not like 'L#_%' escape '#' and p.type in ('PROCEDURE','FUNCTION','ITERATOR')
34+
or i.name not like 'G#_%' escape '#' and p.type not in ('PROCEDURE','FUNCTION','ITERATOR'))
35+
and p.type != 'RECORD'
36+
order by object_name, object_type, line, col;
3337
;
3438

3539
--constants start with c_ or gc_
3640
prompt constants should start with C_
37-
select NAME,TYPE,OBJECT_NAME,OBJECT_TYPE,USAGE,LINE,COL , count(*) over() errcnt_c
38-
from user_identifiers
39-
where type like 'CONSTANT' and usage = 'DECLARATION'
40-
and (name not like 'C#_%' escape '#'
41-
and name not like 'GC#_%' escape '#'
42-
)
43-
order by object_name, object_type, line, col
41+
select i.name, i.type, i.object_name, i.object_type, i.usage, i.line, i.col, count(*) over() errcnt_c
42+
from user_identifiers i
43+
join user_identifiers p
44+
on p.object_name = i.object_name and p.object_type = i.object_type
45+
and i.usage_context_id = p.usage_id
46+
where i.type like 'CONSTANT' and i.usage = 'DECLARATION'
47+
and (i.name not like 'C#_%' escape '#' and p.type in ('PROCEDURE','FUNCTION','ITERATOR')
48+
or i.name not like 'GC#_%' escape '#' and p.type not in ('PROCEDURE','FUNCTION','ITERATOR'))
49+
order by object_name, object_type, line, col
4450
;
4551

4652

4753
exec :errcnt := nvl('&errcnt_a',0) + nvl('&errcnt_l',0) + nvl('&errcnt_c',0);
4854

4955
--quit :errcnt
50-
exit success
56+
exit success

examples/RunAllExamples.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ prompt RunExampleTestAnnotationsHugePackage
2020
@@RunExampleTestAnnotationsHugePackage.sql
2121
prompt RunExpectations
2222
@@RunExpectations.sql
23+
prompt RunWithDocumentationReporter
24+
@@RunWithDocumentationReporter.sql

examples/RunExampleTestSuiteWithCompositeReporter.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ begin
3333
suite.add_item(testtoexecute);
3434

3535
-- provide a reporter to process results
36-
reporter := ut_composite_reporter(ut_reporters_list(ut_dbms_output_suite_reporter, ut_dbms_output_suite_reporter));
36+
reporter := ut_composite_reporter(ut_reporters_list(ut_documentation_reporter, ut_teamcity_reporter));
3737
suite.do_execute(reporter);
3838
end;
3939
/

examples/RunExampleTestSuiteWithDBMSOutputReporter.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ begin
3232
suite.add_item(testtoexecute);
3333

3434
-- provide a reporter to process results
35-
reporter := ut_dbms_output_suite_reporter;
35+
reporter := ut_documentation_reporter;
3636
suite.do_execute(reporter);
3737
end;
3838
/

examples/RunExampleTestThroughBaseClass.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ begin
1919
,a_setup_procedure => 'setup'
2020
,a_teardown_procedure => 'teardown');
2121

22-
reporter := ut_dbms_output_suite_reporter;
22+
reporter := ut_documentation_reporter;
2323
simple_test.do_execute(reporter);
2424
end;
2525
/

examples/RunExpectations.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
--Suite Management packages are when developed will make this easier.
44
--Clear Screen
55
Set Serveroutput On Size Unlimited format truncated
6-
set linesize 1000
6+
set linesize 10000
77
set echo off
88
--install the example unit test packages
99
@@department.tps
@@ -13,7 +13,7 @@ set echo off
1313
@@ut_custom_reporter.tpb
1414

1515
begin
16-
ut_suite_manager.run_cur_schema_suites_static(ut_custom_reporter(a_tab_size => 2), a_force_parse_again => true);
16+
ut_suite_manager.run_cur_schema_suites_static(ut_documentation_reporter(), a_force_parse_again => true);
1717
end;
1818
/
1919

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
Set Serveroutput On Size Unlimited format truncated
2+
set linesize 10000
3+
set echo off
4+
5+
create or replace package demo_doc_reporter1 is
6+
-- %suite(Demo of documentation reporter)
7+
-- %test(A passing test sample)
8+
procedure passing_test;
9+
-- %test
10+
procedure test_without_name;
11+
-- %test(A failing test exsample)
12+
procedure failing_test;
13+
-- %test
14+
procedure failing_no_name;
15+
-- %test(repoting exception)
16+
procedure failing_exception_raised;
17+
end;
18+
/
19+
20+
create or replace package body demo_doc_reporter1 is
21+
22+
procedure passing_test is begin null; end;
23+
24+
procedure test_without_name is
25+
begin
26+
ut.expect(1).to_(equal(1));
27+
end;
28+
29+
procedure failing_test is
30+
begin
31+
ut.expect(1).to_(equal(2));
32+
end;
33+
procedure failing_no_name is
34+
begin
35+
ut.expect(sysdate).to_(equal(to_char(sysdate)));
36+
end;
37+
procedure failing_exception_raised is
38+
l_date date;
39+
begin
40+
l_date := to_date('abcd');
41+
end;
42+
end;
43+
/
44+
45+
create or replace package demo_doc_reporter2 is
46+
-- %suite(A suite pacakge without body)
47+
-- %test(A test)
48+
procedure passing_test1;
49+
-- %test
50+
procedure passing_test2;
51+
end;
52+
/
53+
54+
create or replace package suite_package_without_name is
55+
-- %suite
56+
-- %test(A passing test sample)
57+
procedure passing_test1;
58+
-- %test(A passing test sample)
59+
procedure passing_test2;
60+
end;
61+
/
62+
63+
create or replace package body suite_package_without_name is
64+
65+
procedure passing_test1 is begin null; end;
66+
67+
procedure passing_test2 is
68+
begin
69+
ut.expect(1).to_(equal(1));
70+
end;
71+
end;
72+
/
73+
74+
begin
75+
ut_suite_manager.run_cur_schema_suites_static(ut_documentation_reporter(), a_force_parse_again => true);
76+
end;
77+
/
78+
79+
80+
drop package demo_doc_reporter2;
81+
drop package suite_package_without_name;
82+
drop package demo_doc_reporter1;

examples/ut_custom_reporter.tpb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ create or replace type body ut_custom_reporter is
99
return;
1010
end;
1111

12-
member function tab(self in ut_custom_reporter) return varchar2 is
12+
overriding member function tab(self in ut_custom_reporter) return varchar2 is
1313
tab_str varchar2(255);
1414
begin
1515
tab_str := rpad(' ', lvl * tab_size);
@@ -18,38 +18,38 @@ create or replace type body ut_custom_reporter is
1818

1919
overriding member procedure print_text(a_text varchar2) is
2020
begin
21-
(self as ut_dbms_output_suite_reporter).print_text(tab || a_text);
21+
(self as ut_documentation_reporter).print_text(tab || a_text);
2222
end;
2323

2424
overriding member procedure before_suite(self in out nocopy ut_custom_reporter, a_suite ut_object) as
2525
begin
26-
(self as ut_dbms_output_suite_reporter).before_suite(a_suite);
26+
(self as ut_documentation_reporter).before_suite(a_suite);
2727
lvl := lvl + 1;
2828
end;
2929

3030
overriding member procedure before_test(self in out nocopy ut_custom_reporter, a_test ut_object) as
3131
begin
32-
(self as ut_dbms_output_suite_reporter).before_test(a_test);
32+
(self as ut_documentation_reporter).before_test(a_test);
3333
lvl := lvl + 1;
3434
end;
3535

3636
overriding member procedure on_assert_process(self in out nocopy ut_custom_reporter, a_assert ut_object) is
3737
begin
3838
lvl := lvl + 1;
39-
(self as ut_dbms_output_suite_reporter).on_assert_process(a_assert);
39+
(self as ut_documentation_reporter).on_assert_process(a_assert);
4040
lvl := lvl - 1;
4141
end;
4242

4343
overriding member procedure after_test(self in out nocopy ut_custom_reporter, a_test ut_object) as
4444
begin
4545
lvl := lvl - 1;
46-
(self as ut_dbms_output_suite_reporter).after_test(a_test);
46+
(self as ut_documentation_reporter).after_test(a_test);
4747
end;
4848

4949
overriding member procedure after_suite(self in out nocopy ut_custom_reporter, a_suite ut_object) as
5050
begin
5151
lvl := lvl - 1;
52-
(self as ut_dbms_output_suite_reporter).after_suite(a_suite);
52+
(self as ut_documentation_reporter).after_suite(a_suite);
5353
end;
5454

5555
end;

examples/ut_custom_reporter.tps

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
create or replace type ut_custom_reporter under ut_dbms_output_suite_reporter
1+
create or replace type ut_custom_reporter under ut_documentation_reporter
22
(
3-
lvl integer,
43
tab_size integer,
54

65
-- Member functions and procedures
76
constructor function ut_custom_reporter(a_tab_size integer default 4, a_output ut_output default ut_output_dbms_output() ) return self as result,
8-
member function tab(self in ut_custom_reporter) return varchar2,
7+
overriding member function tab(self in ut_custom_reporter) return varchar2,
98
overriding member procedure print_text(a_text varchar2),
109
overriding member procedure before_suite(self in out nocopy ut_custom_reporter, a_suite ut_object),
1110
overriding member procedure before_test(self in out nocopy ut_custom_reporter, a_test ut_object),

source/core/types/ut_assert_result.tpb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ create or replace type body ut_assert_result is
77
self.object_type := 0;
88
self.result := a_result;
99
self.error_message := a_error_message;
10+
self.caller_info := ut_assert_processor.who_called_expectation();
1011
return;
1112
end ut_assert_result;
1213

@@ -24,6 +25,9 @@ create or replace type body ut_assert_result is
2425
self.actual_type := a_actual_type;
2526
self.expected_value_string := a_expected_value_string;
2627
self.actual_value_string := a_actual_value_string;
28+
if a_result = ut_utils.tr_failure then
29+
self.caller_info := ut_assert_processor.who_called_expectation();
30+
end if;
2731
return;
2832
end ut_assert_result;
2933

0 commit comments

Comments
 (0)