Skip to content

Commit ae9b5fe

Browse files
committed
Refactoring of unit test base classes.
1 parent fcfae1e commit ae9b5fe

105 files changed

Lines changed: 1363 additions & 1293 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

client_source/sqlplus/ut_run.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ begin
107107
p( 'spool ut_run.dbms_output.log');
108108
p( 'declare');
109109
p( ' v_reporter ut_reporter;');
110-
p( ' v_reporters_list ut_reporters_list := ut_reporters_list();');
110+
p( ' v_reporters_list ut_reporters := ut_reporters();');
111111
p( 'begin');
112112
for i in 1 .. cardinality(l_run_params.call_params) loop
113113
p(' v_reporter := '||l_run_params.call_params(i).ut_reporter_name||'('||l_output_type||'());');
114114
p(' v_reporter.output.output_id := '''||l_run_params.call_params(i).output_id||''';');
115115
p(' v_reporters_list.extend; v_reporters_list(v_reporters_list.last) := v_reporter;');
116116
end loop;
117-
p( ' ut.run( ut_varchar2_list('||l_run_params.ut_paths||'), ut_composite_reporter( v_reporters_list ) );');
117+
p( ' ut_runner.run( ut_varchar2_list('||l_run_params.ut_paths||'), v_reporters_list );');
118118
p( 'end;');
119119
p( '/');
120120
p( 'spool off');

examples/RunAllExamples.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ set feedback off
55
set linesize 1000
66
prompt RunExampleComplexSuiteWithCustomDBMSOutputReporter
77
@@RunExampleComplexSuiteWithCustomDBMSOutputReporter.sql
8+
prompt RunExampleTestAnnotationBasedForCurrentSchema
9+
@@RunExampleTestAnnotationBasedForCurrentSchema.sql
10+
prompt RunExampleTestAnnotationsHugePackage
11+
@@RunExampleTestAnnotationsHugePackage.sql
812
prompt RunExampleTestSuite
913
@@RunExampleTestSuite.sql
14+
prompt RunExampleTestSuiteWithCompositeReporter
15+
@@RunExampleTestSuiteWithCompositeReporter.sql
1016
prompt RunExampleTestSuiteWithCustomDBMSOutputReporter
1117
@@RunExampleTestSuiteWithCustomDBMSOutputReporter.sql
1218
prompt RunExampleTestSuiteWithDBMSOutputReporter
1319
@@RunExampleTestSuiteWithDBMSOutputReporter.sql
1420
prompt RunExampleTestThroughBaseClass
1521
@@RunExampleTestThroughBaseClass.sql
16-
prompt RunExampleTestSuiteWithCompositeReporter
17-
@@RunExampleTestSuiteWithCompositeReporter.sql
18-
prompt RunExampleTestAnnotationBasedForCurrentSchema
19-
@@RunExampleTestAnnotationBasedForCurrentSchema.sql
20-
prompt RunExampleTestAnnotationsHugePackage
21-
@@RunExampleTestAnnotationsHugePackage.sql
2222
prompt RunExpectations
2323
@@RunExpectations.sql
2424

examples/RunExampleComplexSuiteWithCustomDBMSOutputReporter.sql

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,38 @@ set echo off
1313
@@ut_custom_reporter.tpb
1414

1515
declare
16-
suite1 ut_test_suite;
17-
suite2 ut_test_suite;
18-
suite_complex ut_test_suite;
19-
testtoexecute ut_test;
20-
reporter ut_reporter;
16+
suite1 ut_suite;
17+
suite2 ut_suite;
18+
suite_complex ut_suite;
19+
listener ut_execution_listener;
2120
begin
22-
suite1 := ut_test_suite(a_suite_name => 'Test Suite 1', a_object_name => null /*,a_items => ut_test_objects_list()*/);
23-
24-
testtoexecute := ut_test(a_object_name => 'ut_exampletest'
25-
,a_test_procedure => 'ut_exAmpletest'
26-
,a_test_name => 'Example test1'
27-
,a_setup_procedure => 'Setup'
28-
,a_teardown_procedure => 'tEardown');
29-
30-
suite1.add_item(testtoexecute);
31-
32-
suite2 := ut_test_suite(a_suite_name => 'Test Suite 2', a_object_name => null /*,a_items => ut_test_objects_list()*/);
33-
testtoexecute := ut_test(a_object_name => 'UT_EXAMPLETEST2'
34-
,a_test_procedure => 'UT_EXAMPLETEST'
35-
,a_setup_procedure => 'SETUP'
36-
,a_teardown_procedure => 'TEARDOWN');
37-
38-
suite2.add_item(testtoexecute);
39-
40-
suite_complex := ut_test_suite(a_suite_name => 'Complex Test Suite', a_object_name => null, a_items => ut_objects_list(suite1, suite2));
21+
suite1 := ut_suite(a_object_owner=>null, a_object_name => null, a_name => null, a_description => 'Test Suite 1');
22+
23+
suite1.add_item(
24+
ut_test(a_object_name => 'ut_exampletest'
25+
,a_name => 'ut_exAmpletest'
26+
,a_description => 'Example test1'
27+
,a_before_test_proc_name => 'Setup'
28+
,a_after_test_proc_name => 'tEardown')
29+
);
30+
31+
suite2 := ut_suite(a_object_owner=>null, a_object_name => null, a_name => null, a_description => 'Test Suite 2');
32+
33+
suite2.add_item(
34+
ut_test(
35+
a_object_name => 'UT_EXAMPLETEST2',
36+
a_name => 'UT_EXAMPLETEST',
37+
a_description => 'Another example test',
38+
a_before_test_proc_name => 'SETUP',
39+
a_after_test_proc_name => 'TEARDOWN')
40+
);
41+
42+
suite_complex := ut_suite( a_object_owner=>null, a_object_name => null, a_name => null, a_description => 'Complex Test Suite');
43+
suite_complex.items := ut_suite_items(suite1, suite2);
4144

4245
-- provide a reporter to process results
43-
reporter := ut_custom_reporter(a_tab_size => 2);
44-
suite_complex.do_execute(reporter);
46+
listener := ut_execution_listener(ut_reporters(ut_custom_reporter(a_tab_size => 2)));
47+
suite_complex.do_execute(listener);
4548
end;
4649
/
4750

examples/RunExampleTestAnnotationsHugePackage.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set echo off
88
@@tst_pkg_huge.pks
99

1010
declare
11-
l_suite ut_test_suite;
11+
l_suite ut_suite;
1212
begin
1313
l_suite := ut_suite_manager.config_package(a_owner_name => USER,a_object_name => 'TST_PKG_HUGE');
1414
end;

examples/RunExampleTestSuite.sql

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--Shows how to create a test suite in code and call the test runner.
2-
--No tables are used for this.
2+
--No tables are used for this.
33
--Suite Management packages are when developed will make this easier.
44
--Clear Screen
55
Set Serveroutput On Size Unlimited format truncated
@@ -11,38 +11,42 @@ set echo off
1111
@@ut_exampletest2.pkb
1212

1313
declare
14-
suite ut_test_suite;
15-
testtoexecute ut_test;
14+
suite ut_suite;
15+
listener ut_execution_listener := ut_execution_listener(ut_reporters());
1616
test_item ut_test;
17-
assert ut_assert_result;
17+
assert ut_assert_result;
1818
begin
19-
suite := ut_test_suite(a_suite_name => 'Test Suite Name', a_object_name => 'ut_exampletest' /*,a_items => ut_test_objects_list()*/);
19+
suite := ut_suite(a_object_owner=>null, a_object_name => 'ut_exampletest', a_name => null, a_description => 'Test Suite Name');
2020

21-
testtoexecute := ut_test(a_object_name => 'ut_exampletest'
22-
,a_test_procedure => 'ut_exAmpletest'
23-
,a_setup_procedure => 'Setup'
24-
,a_teardown_procedure => 'tEardown');
21+
suite.add_item(
22+
ut_test(a_object_name => 'ut_exampletest'
23+
,a_name => 'ut_exAmpletest'
24+
,a_description => 'Example test1'
25+
,a_before_test_proc_name => 'Setup'
26+
,a_after_test_proc_name => 'tEardown')
27+
);
2528

26-
suite.add_item(testtoexecute);
29+
suite.add_item(
30+
ut_test(
31+
a_object_name => 'UT_EXAMPLETEST2',
32+
a_name => 'UT_EXAMPLETEST',
33+
a_description => 'Another example test',
34+
a_before_test_proc_name => 'SETUP',
35+
a_after_test_proc_name => 'TEARDOWN')
36+
);
2737

28-
testtoexecute := ut_test(a_object_name => 'UT_EXAMPLETEST2'
29-
,a_test_procedure => 'UT_EXAMPLETEST'
30-
,a_setup_procedure => 'SETUP'
31-
,a_teardown_procedure => 'TEARDOWN');
32-
33-
suite.add_item(testtoexecute);
34-
suite.do_execute;
38+
suite.do_execute(listener);
3539

3640
-- No reporter used in this example so outputing the results manually.
3741
for test_idx in suite.items.first .. suite.items.last loop
3842
test_item := treat(suite.items(test_idx) as ut_test);
3943
dbms_output.put_line('---------------------------------------------------');
40-
dbms_output.put_line('Test:' || test_item.test.form_name);
41-
dbms_output.put_line('Result: ' || test_item.result_to_char);
44+
dbms_output.put_line('Test:' || test_item.item.form_name);
45+
dbms_output.put_line('Result: ' || ut_utils.test_result_to_char(test_item.result));
4246
dbms_output.put_line('Assert Results:');
43-
for i in test_item.items.first .. test_item.items.last loop
44-
assert := treat(test_item.items(i) as ut_assert_result);
45-
dbms_output.put_line(i || ' - result: ' || assert.result_to_char);
47+
for i in test_item.results.first .. test_item.results.last loop
48+
assert := test_item.results(i);
49+
dbms_output.put_line(i || ' - result: ' || ut_utils.test_result_to_char(assert.result));
4650
dbms_output.put_line(i || ' - Message: ' || assert.message);
4751
end loop;
4852
end loop;

examples/RunExampleTestSuiteWithCompositeReporter.sql

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,31 @@ set echo off
1212

1313
PROMPT Runs test report using composite reporter
1414
declare
15-
suite ut_test_suite;
16-
testtoexecute ut_test;
17-
reporter ut_reporter;
15+
suite ut_suite;
16+
listener ut_execution_listener;
1817
begin
19-
suite := ut_test_suite(a_suite_name => 'Test Suite Name', a_object_name => 'ut_exampletest' /*,a_items => ut_test_objects_list()*/);
18+
suite := ut_suite(a_object_owner=>null, a_object_name => 'ut_exampletest', a_name => null, a_description => 'Test Suite Name');
2019

21-
testtoexecute := ut_test(a_object_name => 'ut_exampletest'
22-
,a_test_procedure => 'ut_exAmpletest'
23-
,a_setup_procedure => 'Setup'
24-
,a_teardown_procedure => 'tEardown');
20+
suite.add_item(
21+
ut_test(a_object_name => 'ut_exampletest'
22+
,a_name => 'ut_exAmpletest'
23+
,a_description => 'Example test1'
24+
,a_before_test_proc_name => 'Setup'
25+
,a_after_test_proc_name => 'tEardown')
26+
);
2527

26-
suite.add_item(testtoexecute);
27-
28-
testtoexecute := ut_test(a_object_name => 'UT_EXAMPLETEST2'
29-
,a_test_procedure => 'UT_EXAMPLETEST'
30-
,a_setup_procedure => 'SETUP'
31-
,a_teardown_procedure => 'TEARDOWN');
32-
33-
suite.add_item(testtoexecute);
28+
suite.add_item(
29+
ut_test(
30+
a_object_name => 'UT_EXAMPLETEST2',
31+
a_name => 'UT_EXAMPLETEST',
32+
a_description => 'Another example test',
33+
a_before_test_proc_name => 'SETUP',
34+
a_after_test_proc_name => 'TEARDOWN')
35+
);
3436

3537
-- provide a reporter to process results
36-
reporter := ut_composite_reporter(ut_reporters_list(ut_documentation_reporter, ut_teamcity_reporter));
37-
suite.do_execute(reporter);
38+
listener := ut_execution_listener(ut_reporters(ut_documentation_reporter, ut_teamcity_reporter));
39+
suite.do_execute(listener);
3840
end;
3941
/
4042

examples/RunExampleTestSuiteWithCustomDBMSOutputReporter.sql

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,33 @@ set echo off
1414
@@ut_custom_reporter.tpb
1515

1616
declare
17-
suite ut_test_suite;
18-
testtoexecute ut_test;
19-
reporter ut_reporter;
17+
suite ut_suite;
18+
listener ut_execution_listener;
2019
begin
2120
-- Install ut_custom_reporter first from example folder
2221

23-
suite := ut_test_suite(a_suite_name => 'Test Suite Name', a_object_name => 'ut_exampletest' /*,a_items => ut_test_objects_list()*/);
24-
25-
testtoexecute := ut_test(a_object_name => 'ut_exampletest'
26-
,a_test_procedure => 'ut_exAmpletest'
27-
,a_setup_procedure => 'Setup'
28-
,a_teardown_procedure => 'tEardown');
29-
30-
suite.add_item(testtoexecute);
31-
32-
testtoexecute := ut_test(a_object_name => 'UT_EXAMPLETEST2'
33-
,a_test_procedure => 'UT_EXAMPLETEST'
34-
,a_setup_procedure => 'SETUP'
35-
,a_teardown_procedure => 'TEARDOWN');
36-
37-
suite.add_item(testtoexecute);
22+
suite := ut_suite(a_object_owner=>null, a_object_name => 'ut_exampletest', a_name => null, a_description => 'Test Suite Name');
23+
24+
suite.add_item(
25+
ut_test(a_object_name => 'ut_exampletest'
26+
,a_name => 'ut_exAmpletest'
27+
,a_description => 'Example test1'
28+
,a_before_test_proc_name => 'Setup'
29+
,a_after_test_proc_name => 'tEardown')
30+
);
31+
32+
suite.add_item(
33+
ut_test(
34+
a_object_name => 'UT_EXAMPLETEST2',
35+
a_name => 'UT_EXAMPLETEST',
36+
a_description => 'Another example test',
37+
a_before_test_proc_name => 'SETUP',
38+
a_after_test_proc_name => 'TEARDOWN')
39+
);
3840

3941
-- provide a reporter to process results tabbing each hierarcy level by tab_size
40-
reporter := ut_custom_reporter(a_tab_size => 2);
41-
suite.do_execute(reporter);
42+
listener := ut_execution_listener(ut_reporters(ut_custom_reporter(a_tab_size => 2)));
43+
suite.do_execute(listener);
4244
end;
4345
/
4446

examples/RunExampleTestSuiteWithDBMSOutputReporter.sql

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,33 @@ set echo off
1111
@@ut_exampletest2.pkb
1212

1313
declare
14-
suite ut_test_suite;
15-
testtoexecute ut_test;
16-
reporter ut_reporter;
14+
suite ut_suite;
15+
listener ut_execution_listener;
1716
begin
18-
suite := ut_test_suite(a_suite_name => 'Test Suite Name', a_object_name => 'ut_exampletest' /*,a_items => ut_test_objects_list()*/);
17+
-- Install ut_custom_reporter first from example folder
1918

20-
testtoexecute := ut_test(a_object_name => 'ut_exampletest'
21-
,a_test_procedure => 'ut_exAmpletest'
22-
,a_setup_procedure => 'Setup'
23-
,a_teardown_procedure => 'tEardown');
19+
suite := ut_suite(a_object_owner=>null, a_object_name => 'ut_exampletest', a_name => null, a_description => 'Test Suite Name');
2420

25-
suite.add_item(testtoexecute);
21+
suite.add_item(
22+
ut_test(a_object_name => 'ut_exampletest'
23+
,a_name => 'ut_exAmpletest'
24+
,a_description => 'Example test1'
25+
,a_before_test_proc_name => 'Setup'
26+
,a_after_test_proc_name => 'tEardown')
27+
);
2628

27-
testtoexecute := ut_test(a_object_name => 'UT_EXAMPLETEST2'
28-
,a_test_procedure => 'UT_EXAMPLETEST'
29-
,a_setup_procedure => 'SETUP'
30-
,a_teardown_procedure => 'TEARDOWN');
31-
32-
suite.add_item(testtoexecute);
29+
suite.add_item(
30+
ut_test(
31+
a_object_name => 'UT_EXAMPLETEST2',
32+
a_name => 'UT_EXAMPLETEST',
33+
a_description => 'Another example test',
34+
a_before_test_proc_name => 'SETUP',
35+
a_after_test_proc_name => 'TEARDOWN')
36+
);
3337

3438
-- provide a reporter to process results
35-
reporter := ut_documentation_reporter;
36-
suite.do_execute(reporter);
39+
listener := ut_execution_listener(ut_reporters(ut_documentation_reporter()));
40+
suite.do_execute(listener);
3741
end;
3842
/
3943

examples/RunExampleTestThroughBaseClass.sql

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ set echo off
99

1010
declare
1111
simple_test ut_test;
12-
reporter ut_reporter;
12+
listener ut_execution_listener;
1313
begin
1414

15-
simple_test := ut_test(a_object_name => 'ut_exampletest'
16-
,a_test_procedure => 'ut_exampletest'
17-
,a_test_name => 'Simple test1'
18-
,a_owner_name => user
19-
,a_setup_procedure => 'setup'
20-
,a_teardown_procedure => 'teardown');
15+
simple_test := ut_test(
16+
a_object_name => 'ut_exampletest'
17+
, a_name => 'ut_exampletest'
18+
, a_description => 'Example test1'
19+
, a_before_test_proc_name => 'setup'
20+
, a_after_test_proc_name => 'teardown');
2121

22-
reporter := ut_documentation_reporter;
23-
simple_test.do_execute(reporter);
22+
listener := ut_execution_listener(ut_reporters(ut_documentation_reporter()));
23+
simple_test.do_execute(listener);
2424
end;
2525
/
2626

examples/RunWithDocumentationReporter.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ end;
4343
/
4444

4545
create or replace package demo_doc_reporter2 is
46-
-- %suite(A suite pacakge without body)
46+
-- %suite(A suite package without body)
4747
-- %test(A test)
48-
procedure passing_test1;
48+
procedure test1;
4949
-- %test
50-
procedure passing_test2;
50+
procedure test2;
5151
end;
5252
/
5353

0 commit comments

Comments
 (0)