@@ -136,10 +136,7 @@ create or replace package test_package as
136136end;
137137/
138138create or replace package body test_package as
139- procedure some_test is
140- begin
141- null ;
142- end;
139+ procedure some_test is begin null ; end;
143140end;
144141/
145142```
@@ -164,10 +161,7 @@ create or replace package test_package as
164161end;
165162/
166163create or replace package body test_package as
167- procedure some_test is
168- begin
169- null ;
170- end;
164+ procedure some_test is begin null ; end;
171165end;
172166/
173167```
@@ -194,10 +188,7 @@ create or replace package test_package as
194188end;
195189/
196190create or replace package body test_package as
197- procedure some_test is
198- begin
199- null ;
200- end;
191+ procedure some_test is begin null ; end;
201192end;
202193/
203194```
@@ -237,14 +228,10 @@ create or replace package test_package as
237228end;
238229/
239230create or replace package body test_package as
240- procedure some_test is
241- begin
242- null ;
243- end;
244- procedure other_test is
245- begin
246- null ;
247- end;
231+
232+ procedure some_test is begin null ; end;
233+
234+ procedure other_test is begin null ; end;
248235end;
249236/
250237```
@@ -275,14 +262,10 @@ create or replace package test_package as
275262end;
276263/
277264create or replace package body test_package as
278- procedure some_test is
279- begin
280- null ;
281- end;
282- procedure other_test is
283- begin
284- null ;
285- end;
265+
266+ procedure some_test is begin null ; end;
267+
268+ procedure other_test is begin null ; end;
286269end;
287270/
288271```
@@ -324,14 +307,10 @@ create or replace package body test_package as
324307 begin
325308 dbms_output .put_line (' --- SETUP_STUFF invoked ---' );
326309 end;
327- procedure some_test is
328- begin
329- null ;
330- end;
331- procedure other_test is
332- begin
333- null ;
334- end;
310+
311+ procedure some_test is begin null ; end;
312+
313+ procedure other_test is begin null ; end;
335314end;
336315/
337316```
@@ -351,7 +330,8 @@ Finished in .012292 seconds
351330
352331
353332When you define multiple beforeall procedures, all of them will get executed before invoking any test in package.
354- Order of execution for beforeall procedures is defined by the position of the ` --%beforeall ` annotation in the package specification.
333+ Order of execution for beforeall procedures is defined by the position of the ` --%beforeall ` annotation in the package specification.
334+ Note that procedure ` another_setup ` is also invoked before any test, though it's located at the end of package specification.
355335 ``` sql
356336 create or replace package test_package as
357337 -- %suite(Tests for a package)
@@ -375,18 +355,62 @@ Order of execution for beforeall procedures is defined by the position of the `-
375355 begin
376356 dbms_output .put_line (' --- ANOTHER_SETUP invoked ---' );
377357 end;
358+
378359 procedure initial_setup is
379360 begin
380361 dbms_output .put_line (' --- INITIAL_SETUP invoked ---' );
381362 end;
382- procedure some_test is
383- begin
384- null ;
385- end;
386- procedure other_test is
363+
364+ procedure some_test is begin null ; end;
365+
366+ procedure other_test is begin null ; end;
367+ end;
368+ /
369+ ```
370+
371+ ``` sql
372+ exec ut .run (' test_package' );
373+ ```
374+ ```
375+ Tests for a package
376+ --- INITIAL_SETUP invoked ---
377+ --- ANOTHER_SETUP invoked ---
378+ Description of tesed behavior [.004 sec]
379+ Description of another behavior [.004 sec]
380+
381+ Finished in .016672 seconds
382+ 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)
383+ ```
384+
385+ When multiple ` --%beforeall ` annotations are specified for a procedure, the first annotation will be used and a warning message will appear indicating duplicate annotation.
386+ 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.
387+ ``` sql
388+ create or replace package test_package as
389+ -- %suite(Tests for a package)
390+
391+ -- %beforeall
392+ -- %beforeall
393+ procedure initial_setup;
394+
395+ -- %test(Description of tesed behavior)
396+ -- %beforeall
397+ procedure some_test;
398+
399+ -- %test(Description of another behavior)
400+ procedure other_test;
401+
402+ end;
403+ /
404+ create or replace package body test_package as
405+
406+ procedure initial_setup is
387407 begin
388- null ;
408+ dbms_output . put_line ( ' --- INITIAL_SETUP invoked --- ' ) ;
389409 end;
410+
411+ procedure some_test is begin null ; end;
412+
413+ procedure other_test is begin null ; end;
390414 end;
391415 /
392416```
0 commit comments