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

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c787e47
Added support for multiple occurrences of before and after blocks.
jgebal Mar 4, 2018
2399981
tmp
jgebal Mar 14, 2018
2631355
Fixed issue with null items list.
jgebal Mar 15, 2018
a05475a
Redefined event listeners mechanism.
jgebal Mar 25, 2018
f955d2a
Redefined event listeners mechanism.
jgebal Mar 25, 2018
430f76f
Fixed minor bug in XUnit reporter (showing CDATA for errors even when…
jgebal Mar 25, 2018
2537ced
Changed propagation of rollback. Now rollback will propagate from par…
jgebal Mar 29, 2018
9308662
Fixed examples.
jgebal Mar 29, 2018
17ee8cb
Fixed test for empty description in 11g.
jgebal Mar 29, 2018
93be873
Fixed test for empty description in 11g.
jgebal Mar 29, 2018
75b96c3
Fixed double warning on missing endcontext annotation.
jgebal Mar 29, 2018
a6dadcc
fix in test to overcome 11g XML missing attributes in 3.0.4
jgebal Mar 30, 2018
4bc7ced
Merge branch 'develop' into feature/support_of_context
jgebal Apr 7, 2018
8a26845
Fixes after merging from develop.
jgebal Apr 7, 2018
e9c4e80
Fixed test failure on 11g R2 - some issues with LIKE operator, long p…
jgebal Apr 7, 2018
bfbfa43
Updated documentation.
jgebal Apr 7, 2018
9cd61bf
Marking first column as bold
jgebal Apr 7, 2018
1adf35d
Changed the way reporters events are registered.
jgebal Apr 14, 2018
71d0b70
Fixed issues with comment-replace in big package specs.
jgebal Apr 14, 2018
8617613
Updated test for comments removal to include multi-line comments with…
jgebal Apr 16, 2018
51ba943
Updated documentation with new and changed annotations.
jgebal Apr 16, 2018
ad3f830
Changed behaviour for duplicate annotations - first wins.
jgebal Apr 19, 2018
4346b57
Updates to documentation.
jgebal Apr 20, 2018
b1ff0fc
Updates to documentation.
jgebal Apr 20, 2018
ab5a1ca
Updated and extended documentation for annotations.
jgebal Apr 22, 2018
e672ef0
Added description of `context` to annotations documentation.
jgebal Apr 22, 2018
9897247
Merge remote-tracking branch 'origin/develop' into feature/support_of…
jgebal Apr 22, 2018
b2df93e
Integrated with develop branch changes.
jgebal Apr 22, 2018
d604127
Removed empty header from documentation.
jgebal Apr 24, 2018
9afb7be
A bit of code cleanup and tests alignment.
jgebal Apr 25, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updates to documentation.
Added additional warnings.
  • Loading branch information
jgebal committed Apr 20, 2018
commit b1ff0fc57edd96675efbe2e70475745c5ec70458
110 changes: 67 additions & 43 deletions docs/userguide/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@ create or replace package test_package as
end;
/
create or replace package body test_package as
procedure some_test is
begin
null;
end;
procedure some_test is begin null; end;
end;
/
```
Expand All @@ -164,10 +161,7 @@ create or replace package test_package as
end;
/
create or replace package body test_package as
procedure some_test is
begin
null;
end;
procedure some_test is begin null; end;
end;
/
```
Expand All @@ -194,10 +188,7 @@ create or replace package test_package as
end;
/
create or replace package body test_package as
procedure some_test is
begin
null;
end;
procedure some_test is begin null; end;
end;
/
```
Expand Down Expand Up @@ -237,14 +228,10 @@ create or replace package test_package as
end;
/
create or replace package body test_package as
procedure some_test is
begin
null;
end;
procedure other_test is
begin
null;
end;

procedure some_test is begin null; end;

procedure other_test is begin null; end;
end;
/
```
Expand Down Expand Up @@ -275,14 +262,10 @@ create or replace package test_package as
end;
/
create or replace package body test_package as
procedure some_test is
begin
null;
end;
procedure other_test is
begin
null;
end;

procedure some_test is begin null; end;

procedure other_test is begin null; end;
end;
/
```
Expand Down Expand Up @@ -324,14 +307,10 @@ create or replace package body test_package as
begin
dbms_output.put_line('--- SETUP_STUFF invoked ---');
end;
procedure some_test is
begin
null;
end;
procedure other_test is
begin
null;
end;

procedure some_test is begin null; end;

procedure other_test is begin null; end;
end;
/
```
Expand All @@ -351,7 +330,8 @@ Finished in .012292 seconds


When you define multiple beforeall procedures, all of them will get executed before invoking any test in package.
Order of execution for beforeall procedures is defined by the position of the `--%beforeall` annotation in the package specification.
Order of execution for beforeall procedures is defined by the position of the `--%beforeall` annotation in the package specification.
Note that procedure `another_setup` is also invoked before any test, though it's located at the end of package specification.
```sql
create or replace package test_package as
--%suite(Tests for a package)
Expand All @@ -375,18 +355,62 @@ Order of execution for beforeall procedures is defined by the position of the `-
begin
dbms_output.put_line('--- ANOTHER_SETUP invoked ---');
end;

procedure initial_setup is
begin
dbms_output.put_line('--- INITIAL_SETUP invoked ---');
end;
procedure some_test is
begin
null;
end;
procedure other_test is

procedure some_test is begin null; end;

procedure other_test is begin null; end;
end;
/
```

```sql
exec ut.run('test_package');
```
```
Tests for a package
--- INITIAL_SETUP invoked ---
--- ANOTHER_SETUP invoked ---
Description of tesed behavior [.004 sec]
Description of another behavior [.004 sec]

Finished in .016672 seconds
2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)
```

When multiple `--%beforeall` annotations are specified for a procedure, the first annotation will be used and a warning message will appear indicating duplicate annotation.
When procedure is annotated as both `--%beforeall` and `--%test`, the procedure will become a test and a warning message will appear indicating invalid annotation combination.
```sql
create or replace package test_package as
--%suite(Tests for a package)

--%beforeall
--%beforeall
procedure initial_setup;

--%test(Description of tesed behavior)
--%beforeall
procedure some_test;

--%test(Description of another behavior)
procedure other_test;

end;
/
create or replace package body test_package as

procedure initial_setup is
begin
null;
dbms_output.put_line('--- INITIAL_SETUP invoked ---');
end;

procedure some_test is begin null; end;

procedure other_test is begin null; end;
end;
/
```
Expand Down
10 changes: 7 additions & 3 deletions source/core/ut_suite_builder.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,6 @@ create or replace package body ut_suite_builder is
begin
l_test := ut_test(a_suite.object_owner, a_suite.object_name, a_procedure_name);

warning_on_duplicate_annot(a_suite, a_procedure_name, a_annotations, 'test');
-- warning_on_duplicate_annot(a_suite, a_procedure_name, a_annotations, 'displayname');
-- warning_on_duplicate_annot(a_suite, a_procedure_name, a_annotations, 'rollback');
if a_annotations.exists('displayname') then
l_annotation_texts := a_annotations('displayname');
--take the last definition if more than one was provided
Expand Down Expand Up @@ -360,6 +357,13 @@ create or replace package body ut_suite_builder is
a_after_each_list in out nocopy ut_executables
) is
begin
warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, 'test');
-- warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, 'displayname');
-- warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, 'rollback');
warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, 'beforeall');
warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, 'beforeeach');
warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, 'afterall');
warning_on_duplicate_annot(a_suite, a_procedure_name, a_proc_annotations, 'aftereach');
if a_proc_annotations.exists('test') then
add_test( a_suite, a_procedure_name, a_proc_annotations);

Expand Down
72 changes: 72 additions & 0 deletions test/core/test_suite_builder.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,78 @@ create or replace package body test_suite_builder is
);
end;

procedure beforeall_annot_duplicated is
l_actual clob;
l_annotations ut3.ut_annotations;
begin
--Arrange
l_annotations := ut3.ut_annotations(
ut3.ut_annotation(2, 'suite','Cool', null),
ut3.ut_annotation(8, 'beforeall', null, 'test_procedure'),
ut3.ut_annotation(9, 'beforeall', null, 'test_procedure')
);
--Act
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
--Assert
ut.expect(l_actual).to_be_like(
'%<DESCRIPTION>Cool</DESCRIPTION>%<WARNINGS>%&quot;--%beforeall&quot;%UT3_TESTER.SOME_PACKAGE.TEST_PROCEDURE%line 9%</WARNINGS>%'
);
end;

procedure beforeeach_annot_duplicated is
l_actual clob;
l_annotations ut3.ut_annotations;
begin
--Arrange
l_annotations := ut3.ut_annotations(
ut3.ut_annotation(2, 'suite','Cool', null),
ut3.ut_annotation(8, 'beforeeach', null, 'test_procedure'),
ut3.ut_annotation(9, 'beforeeach', null, 'test_procedure')
);
--Act
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
--Assert
ut.expect(l_actual).to_be_like(
'%<DESCRIPTION>Cool</DESCRIPTION>%<WARNINGS>%&quot;--%beforeeach&quot;%UT3_TESTER.SOME_PACKAGE.TEST_PROCEDURE%line 9%</WARNINGS>%'
);
end;

procedure afterall_annot_duplicated is
l_actual clob;
l_annotations ut3.ut_annotations;
begin
--Arrange
l_annotations := ut3.ut_annotations(
ut3.ut_annotation(2, 'suite','Cool', null),
ut3.ut_annotation(8, 'afterall', null, 'test_procedure'),
ut3.ut_annotation(9, 'afterall', null, 'test_procedure')
);
--Act
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
--Assert
ut.expect(l_actual).to_be_like(
'%<DESCRIPTION>Cool</DESCRIPTION>%<WARNINGS>%&quot;--%afterall&quot;%UT3_TESTER.SOME_PACKAGE.TEST_PROCEDURE%line 9%</WARNINGS>%'
);
end;

procedure aftereach_annot_duplicated is
l_actual clob;
l_annotations ut3.ut_annotations;
begin
--Arrange
l_annotations := ut3.ut_annotations(
ut3.ut_annotation(2, 'suite','Cool', null),
ut3.ut_annotation(8, 'aftereach', null, 'test_procedure'),
ut3.ut_annotation(9, 'aftereach', null, 'test_procedure')
);
--Act
l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE');
--Assert
ut.expect(l_actual).to_be_like(
'%<DESCRIPTION>Cool</DESCRIPTION>%<WARNINGS>%&quot;--%aftereach&quot;%UT3_TESTER.SOME_PACKAGE.TEST_PROCEDURE%line 9%</WARNINGS>%'
);
end;

procedure suitepath_annot_duplicated is
l_actual clob;
l_annotations ut3.ut_annotations;
Expand Down
12 changes: 12 additions & 0 deletions test/core/test_suite_builder.pks
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ create or replace package test_suite_builder is
--%test(Gives warning if more than one --%test annotation used)
procedure test_annot_duplicated;

--%test(Gives warning if more than one --%beforeall annotation used)
procedure beforeall_annot_duplicated;

--%test(Gives warning if more than one --%beforeeach annotation used)
procedure beforeeach_annot_duplicated;

--%test(Gives warning if more than one --%afterall annotation used)
procedure afterall_annot_duplicated;

--%test(Gives warning if more than one --%aftereach annotation used)
procedure aftereach_annot_duplicated;

--%test(Gives warning if more than one --%suitepath annotation used)
procedure suitepath_annot_duplicated;

Expand Down