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

Skip to content

Commit 8c532ce

Browse files
authored
Merge pull request #629 from utPLSQL/feature/support_of_context
Feature/support of context
2 parents 24c962b + 9afb7be commit 8c532ce

94 files changed

Lines changed: 4150 additions & 1607 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.

docs/userguide/annotations.md

Lines changed: 1198 additions & 144 deletions
Large diffs are not rendered by default.

docs/userguide/expectations.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -780,24 +780,23 @@ Since NULL is neither *true* nor *false*, both expectations will report failure.
780780

781781
The matrix below illustrates the data types supported by different matchers.
782782

783-
| | be_between | be_empty | be_false | be_greater_than | be_greater_or_equal | be_less_or_equal | be_less_than | be_like | be_not_null | be_null | be_true | equal | have_count | match |
784-
|:------------------------------|:----------:|:--------:|:--------:|:---------------:|:-------------------:|:----------------:|:------------:|:-------:|:-----------:|:-------:|:-------:|:-----:|:----------:|:-----:|
785-
| blob | | | | | | | | | X | X | | X | | |
786-
| boolean | | | X | | | | | | X | X | X | X | | |
787-
| clob | | | | | | | | X | X | X | | X | | X |
788-
| date | X | | | X | X | X | X | | X | X | | X | | |
789-
| number | X | | | X | X | X | X | | X | X | | X | | |
790-
| timestamp | X | | | X | X | X | X | | X | X | | X | | |
791-
| timestamp with timezone | X | | | X | X | X | X | | X | X | | X | | |
792-
| timestamp with local timezone | X | | | X | X | X | X | | X | X | | X | | |
793-
| varchar2 | X | | | | | | | X | X | X | | X | | X |
794-
| interval year to month | X | | | X | X | X | X | | X | X | | X | | |
795-
| interval day to second | X | | | X | X | X | X | | X | X | | X | | |
796-
| refcursor | | X | | | | | | | X | X | | X | X | |
797-
| nested table (as anydata) | | X | | | | | | | X | X | | X | X | |
798-
| varray (as anydata) | | X | | | | | | | X | X | | X | X | |
799-
| object (as anydata) | | | | | | | | | X | X | | X | | |
800-
783+
| Matcher |blob |boolean|clob |date |number|timestamp|timestamp<br>with<br>timezone|timestamp<br>with<br>local<br>timezone|varchar2|interval<br>year<br>to<br>month|interval<br>day<br>to<br>second|cursor|nested<br>table<br>/ varray|object|
784+
|:----------------------|:---:|:-----:|:---:|:---:|:----:|:-------:|:---------------------------:|:------------------------------------:|:------:|:-----------------------------:|:-----------------------------:|:----:|:-------------------------:|:----:|
785+
|**be_not_null** | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
786+
|**be_null** | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
787+
|**be_false** | | X | | | | | | | | | | | | |
788+
|**be_true** | | X | | | | | | | | | | | | |
789+
|**be_greater_than** | | | | X | X | X | X | X | | X | X | | | |
790+
|**be_greater_or_equal**| | | | X | X | X | X | X | | X | X | | | |
791+
|**be_less_or_equal** | | | | X | X | X | X | X | | X | X | | | |
792+
|**be_less_than** | | | | X | X | X | X | X | | X | X | | | |
793+
|**be_between** | | | | X | X | X | X | X | X | X | X | | | |
794+
|**equal** | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
795+
|**match** | | | X | | | | | | X | | | | | |
796+
|**be_like** | | | X | | | | | | X | | | | | |
797+
|**be_empty** | | | | | | | | | | | | X | X | |
798+
|**have_count** | | | | | | | | | | | | X | X | |
799+
801800

802801

803802

examples/developer_examples/RunExampleComplexSuiteWithCustomReporter.sql

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,44 @@ set echo off
1313
@@ut_custom_reporter.tpb
1414

1515
declare
16-
suite1 ut_logical_suite;
17-
suite2 ut_logical_suite;
18-
suite_complex ut_logical_suite;
19-
l_reporter ut_output_reporter_base;
20-
l_listener ut_event_listener;
21-
l_run ut_run;
16+
l_parent_suite ut_logical_suite;
17+
l_suite ut_suite;
18+
l_test ut_test;
19+
l_reporter ut_output_reporter_base;
20+
l_run ut_run;
2221
begin
23-
suite1 := ut_logical_suite(a_object_owner=>null, a_object_name => null, a_name => null, a_description => 'Test Suite 1', a_path => null);
24-
25-
suite1.add_item(
26-
ut_test(a_object_name => 'ut_exampletest'
27-
,a_name => 'ut_exAmpletest'
28-
,a_description => 'Example test1'
29-
,a_before_test_proc_name => 'Setup'
30-
,a_after_test_proc_name => 'tEardown')
31-
);
32-
33-
suite2 := ut_logical_suite(a_object_owner=>null, a_object_name => null, a_name => null, a_description => 'Test Suite 2', a_path => null);
34-
35-
suite2.add_item(
36-
ut_test(
37-
a_object_name => 'UT_EXAMPLETEST2',
38-
a_name => 'UT_EXAMPLETEST',
39-
a_description => 'Another example test',
40-
a_before_test_proc_name => 'SETUP',
41-
a_after_test_proc_name => 'TEARDOWN')
42-
);
43-
44-
suite_complex := ut_logical_suite( a_object_owner=>null, a_object_name => null, a_name => null, a_description => 'Complex Test Suite', a_path => null);
45-
suite_complex.items := ut_suite_items(suite1, suite2);
22+
ut_event_manager.initialize();
23+
l_parent_suite := ut_logical_suite( a_object_owner=>null, a_object_name => null, a_name => 'complex_test_suite', a_path => null);
24+
25+
l_suite := ut_suite(user, 'ut_exampletest');
26+
l_test := ut_test(user, 'ut_exampletest','ut_exAmpletest');
27+
l_test.description := 'Example test1';
28+
l_test.before_test_list := ut_executables(ut_executable(user, 'ut_exampletest','Setup',ut_utils.gc_before_test));
29+
l_test.after_test_list := ut_executables(ut_executable(user, 'ut_exampletest','tEardown',ut_utils.gc_after_test));
30+
31+
l_suite.add_item(l_test);
32+
l_parent_suite.add_item(l_suite);
33+
34+
35+
l_suite := ut_suite(user, 'ut_exampletest2');
36+
l_test := ut_test(user, 'UT_EXAMPLETEST2','UT_EXAMPLETEST');
37+
l_test.before_test_list := ut_executables(ut_executable(user, 'UT_EXAMPLETEST2','SETUP',ut_utils.gc_before_test));
38+
l_test.after_test_list := ut_executables(ut_executable(user, 'UT_EXAMPLETEST2','TEARDOWN',ut_utils.gc_after_test));
39+
40+
l_suite.add_item(l_test);
41+
l_parent_suite.add_item(l_suite);
4642

4743
-- provide a reporter to process results
4844
l_reporter := ut_custom_reporter(a_tab_size => 2);
49-
l_listener := ut_event_listener(ut_reporters(l_reporter));
50-
l_run := ut_run(ut_suite_items(suite_complex));
51-
l_run.do_execute(l_listener);
45+
ut_event_manager.add_listener(l_reporter);
46+
l_run := ut_run(ut_suite_items(l_parent_suite));
47+
l_run.do_execute();
48+
ut_event_manager.trigger_event(ut_utils.gc_finalize, l_run);
5249
l_reporter.lines_to_dbms_output();
5350
end;
5451
/
5552

5653
drop type ut_custom_reporter;
5754
drop package ut_exampletest;
5855
drop package ut_exampletest2;
56+
exec dbms_session.reset_package;

examples/developer_examples/RunExampleTestAnnotationsParsingTimeHugePackage.sql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
--Shows that even a very large package specification can be parsed quite quickly
22
--Clear Screen
3-
Set Serveroutput On Size Unlimited format truncated
3+
set serveroutput on
44
set echo off
55
--install the example unit test packages
66
@@tst_pkg_huge.pks
77

88
declare
99
l_suites ut_suite_items;
10+
l_items ut_suite_items;
1011
begin
1112
l_suites := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(USER||'.TST_PKG_HUGE'));
13+
l_items := treat(
14+
treat( treat( l_suites( 1 ) as ut_logical_suite ).items( 1 ) as ut_logical_suite ).items( 1 )
15+
as ut_logical_suite
16+
).items;
17+
dbms_output.put_line('Created '||l_items.count||' tests in suite');
18+
dbms_output.put_line(' Last test name='||l_items(l_items.last).name);
1219
end;
1320
/
1421

examples/developer_examples/RunExampleTestSuite.sql

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,37 @@ set echo off
1111
@@ut_exampletest2.pkb
1212

1313
declare
14-
suite ut_logical_suite;
15-
listener ut_event_listener := ut_event_listener(ut_reporters());
16-
test_item ut_test;
17-
expectation ut_expectation_result;
14+
l_suite ut_logical_suite;
15+
l_test ut_test;
16+
l_expectation ut_expectation_result;
1817
begin
19-
suite := ut_logical_suite(a_object_owner=>null, a_object_name => 'ut_exampletest', a_name => null, a_description => 'Test Suite Name',a_path => null);
18+
l_suite := ut_suite(user, 'ut_exampletest');
19+
l_suite.description := 'Test Suite Name';
20+
l_test := ut_test(user, 'ut_exampletest','ut_exAmpletest');
21+
l_test.description := 'Example test1';
22+
l_test.before_test_list := ut_executables(ut_executable(user, 'ut_exampletest','Setup',ut_utils.gc_before_test));
23+
l_test.after_test_list := ut_executables(ut_executable(user, 'ut_exampletest','tEardown',ut_utils.gc_after_test));
24+
l_suite.add_item(l_test);
2025

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-
);
26+
l_test := ut_test(user, 'UT_EXAMPLETEST2','ut_exAmpletest');
27+
l_test.description := 'Another example test';
28+
l_test.before_test_list := ut_executables(ut_executable(user, 'UT_EXAMPLETEST2','SETUP',ut_utils.gc_before_test));
29+
l_test.after_test_list := ut_executables(ut_executable(user, 'UT_EXAMPLETEST2','TEARDOWN',ut_utils.gc_after_test));
30+
l_suite.add_item(l_test);
2831

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-
);
37-
38-
suite.do_execute(listener);
32+
l_suite.do_execute();
3933

4034
-- No reporter used in this example so outputing the results manually.
41-
for test_idx in suite.items.first .. suite.items.last loop
42-
test_item := treat(suite.items(test_idx) as ut_test);
35+
for test_idx in l_suite.items.first .. l_suite.items.last loop
36+
l_test := treat(l_suite.items(test_idx) as ut_test);
4337
dbms_output.put_line('---------------------------------------------------');
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));
38+
dbms_output.put_line('Test:' || l_test.item.form_name);
39+
dbms_output.put_line('Result: ' || ut_utils.test_result_to_char(l_test.result));
4640
dbms_output.put_line('expectation Results:');
47-
for i in 1 .. test_item.failed_expectations.count loop
48-
expectation := test_item.failed_expectations(i);
49-
dbms_output.put_line(i || ' - result: ' || ut_utils.test_result_to_char(expectation.result));
50-
dbms_output.put_line(i || ' - Message: ' || expectation.message);
41+
for i in 1 .. l_test.failed_expectations.count loop
42+
l_expectation := l_test.failed_expectations(i);
43+
dbms_output.put_line(i || ' - result: ' || ut_utils.test_result_to_char(l_expectation.result));
44+
dbms_output.put_line(i || ' - Message: ' || l_expectation.message);
5145
end loop;
5246
end loop;
5347
dbms_output.put_line('---------------------------------------------------');

examples/developer_examples/RunExampleTestSuiteWithCompositeReporter.sql

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,23 @@ declare
1515
suite ut_logical_suite;
1616
l_doc_reporter ut_output_reporter_base := ut_documentation_reporter();
1717
l_tc_reporter ut_output_reporter_base := ut_teamcity_reporter();
18-
l_listener ut_event_listener := ut_event_listener(ut_reporters(l_doc_reporter, l_tc_reporter));
1918
l_run ut_run;
2019
begin
21-
suite := ut_logical_suite(a_object_owner=>null, a_object_name => 'ut_exampletest', a_name => null, a_description => 'Test Suite Name',a_path => null);
20+
ut_event_manager.initialize();
21+
ut_event_manager.add_listener(l_doc_reporter);
22+
ut_event_manager.add_listener(l_tc_reporter);
2223

23-
suite.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-
);
24+
suite := ut_suite(user, 'ut_exampletest');
25+
suite.description := 'Test Suite Name';
3026

31-
suite.add_item(
32-
ut_test(
33-
a_object_name => 'UT_EXAMPLETEST2',
34-
a_name => 'UT_EXAMPLETEST',
35-
a_description => 'Another example test',
36-
a_before_test_proc_name => 'SETUP',
37-
a_after_test_proc_name => 'TEARDOWN')
38-
);
27+
suite.add_item(ut_test(user,'ut_exampletest','ut_exAmpletest'));
28+
suite.add_item(ut_test(user, 'UT_EXAMPLETEST2','UT_EXAMPLETEST'));
3929

4030
-- provide a reporter to process results
4131
l_run := ut_run(ut_suite_items(suite));
42-
l_run.do_execute(l_listener);
32+
l_run.do_execute();
33+
34+
ut_event_manager.trigger_event(ut_utils.gc_finalize, l_run);
4335
l_doc_reporter.lines_to_dbms_output(0,0);
4436
l_tc_reporter.lines_to_dbms_output(0,0);
4537
end;

examples/developer_examples/RunExampleTestSuiteWithCustomReporter.sql

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,34 @@ set echo off
1414
@@ut_custom_reporter.tpb
1515

1616
declare
17-
suite ut_logical_suite;
17+
l_suite ut_logical_suite;
18+
l_test ut_test;
1819
l_reporter ut_output_reporter_base;
19-
l_listener ut_event_listener;
2020
l_run ut_run;
2121
begin
22+
ut_event_manager.initialize();
2223
-- Install ut_custom_reporter first from example folder
2324

24-
suite := ut_logical_suite(a_object_owner=>null, a_object_name => 'ut_exampletest', a_name => null, a_description => 'Test Suite Name',a_path => null);
25+
l_suite := ut_suite(user, 'ut_exampletest');
2526

26-
suite.add_item(
27-
ut_test(a_object_name => 'ut_exampletest'
28-
,a_name => 'ut_exAmpletest'
29-
,a_description => 'Example test1'
30-
,a_before_test_proc_name => 'Setup'
31-
,a_after_test_proc_name => 'tEardown')
32-
);
27+
l_test := ut_test(user, 'ut_exampletest','ut_exAmpletest');
28+
l_test.description := 'Example test1';
29+
l_test.before_test_list := ut_executables(ut_executable(user, 'ut_exampletest','Setup',ut_utils.gc_before_test));
30+
l_test.after_test_list := ut_executables(ut_executable(user, 'ut_exampletest','tEardown',ut_utils.gc_after_test));
31+
l_suite.add_item(l_test);
3332

34-
suite.add_item(
35-
ut_test(
36-
a_object_name => 'UT_EXAMPLETEST2',
37-
a_name => 'UT_EXAMPLETEST',
38-
a_description => 'Another example test',
39-
a_before_test_proc_name => 'SETUP',
40-
a_after_test_proc_name => 'TEARDOWN')
41-
);
33+
l_test := ut_test(user, 'UT_EXAMPLETEST2','ut_exAmpletest');
34+
l_test.description := 'Another example test';
35+
l_test.before_test_list := ut_executables(ut_executable(user, 'ut_exampletest','SETUP',ut_utils.gc_before_test));
36+
l_test.after_test_list := ut_executables(ut_executable(user, 'ut_exampletest','TEARDOWN',ut_utils.gc_after_test));
37+
l_suite.add_item(l_test);
4238

4339
-- provide a reporter to process results tabbing each hierarcy level by tab_size
4440
l_reporter := ut_custom_reporter(a_tab_size => 2);
45-
l_listener := ut_event_listener(ut_reporters(l_reporter));
46-
l_run := ut_run(ut_suite_items(suite));
47-
l_run.do_execute(l_listener);
41+
ut_event_manager.add_listener(l_reporter);
42+
l_run := ut_run(ut_suite_items(l_suite));
43+
l_run.do_execute();
44+
ut_event_manager.trigger_event(ut_utils.gc_finalize, l_run);
4845
l_reporter.lines_to_dbms_output(0,0);
4946
end;
5047
/
@@ -54,3 +51,4 @@ end;
5451
drop type ut_custom_reporter;
5552
drop package ut_exampletest;
5653
drop package ut_exampletest2;
54+
exec dbms_session.reset_package;

0 commit comments

Comments
 (0)