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

Skip to content

Commit 49ae427

Browse files
committed
Updates to code, move the Coma separated list into ut_runner.
1 parent 6161eae commit 49ae427

7 files changed

Lines changed: 222 additions & 278 deletions

File tree

docs/userguide/running-unit-tests.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ end;
9393
```
9494
Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_.
9595

96+
```sql
97+
begin
98+
ut.run(ut_varchar2_list('hr.test_apply_bonus,cust)');
99+
end;
100+
```
101+
102+
Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_.
103+
96104
```sql
97105
begin
98106
ut.run('hr.test_apply_bonus,cust');
@@ -103,7 +111,7 @@ Executes all tests from package _hr.test_apply_bonus_ and all tests from schema
103111

104112
Using a list of items to execute allows you to execute a fine-grained set of tests.
105113

106-
List can be passed as a comma separated list or a list of *ut_varchar2_list objects*.
114+
List can be passed as a comma separated list or a list of *ut_varchar2_list objects* or as a list within ut_varchar2_list.
107115

108116

109117
**Note:**

source/api/ut.pkb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ create or replace package body ut is
333333
) return ut_varchar2_rows pipelined is
334334
l_reporter ut_reporter_base := coalesce(a_reporter,
335335
ut_documentation_reporter());
336-
l_paths ut_varchar2_list := coalesce(ut_utils.string_to_table(a_string => a_path,a_delimiter => ','),ut_varchar2_list(sys_context('userenv', 'current_schema')));
336+
l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
337337
l_lines sys_refcursor;
338338
l_line varchar2(4000);
339339
begin
@@ -373,7 +373,7 @@ create or replace package body ut is
373373
a_client_character_set varchar2 := null
374374
) return ut_varchar2_rows pipelined is
375375
l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
376-
l_paths ut_varchar2_list := coalesce(ut_utils.string_to_table(a_string => a_path,a_delimiter => ','),ut_varchar2_list(sys_context('userenv', 'current_schema')));
376+
l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
377377
l_lines sys_refcursor;
378378
l_line varchar2(4000);
379379
begin
@@ -520,7 +520,7 @@ create or replace package body ut is
520520
a_exclude_objects ut_varchar2_list := null,
521521
a_client_character_set varchar2 := null
522522
) is
523-
l_paths ut_varchar2_list := coalesce(ut_utils.string_to_table(a_string => a_path,a_delimiter => ','),ut_varchar2_list(sys_context('userenv', 'current_schema')));
523+
l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
524524
begin
525525
ut.run(
526526
l_paths,
@@ -546,7 +546,7 @@ create or replace package body ut is
546546
a_exclude_objects ut_varchar2_list := null,
547547
a_client_character_set varchar2 := null
548548
) is
549-
l_paths ut_varchar2_list := coalesce(ut_utils.string_to_table(a_string => a_path,a_delimiter => ','),ut_varchar2_list(sys_context('userenv', 'current_schema')));
549+
l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
550550
begin
551551
ut.run(
552552
l_paths,

source/api/ut_runner.pkb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,17 @@ create or replace package body ut_runner is
8989
l_coverage_schema_names ut_varchar2_rows;
9090
l_exclude_object_names ut_object_names := ut_object_names();
9191
l_include_object_names ut_object_names;
92+
l_paths ut_varchar2_list := ut_varchar2_list();
9293
begin
9394
ut_event_manager.initialize();
9495
begin
9596
ut_expectation_processor.reset_invalidation_exception();
9697
ut_utils.save_dbms_output_to_cache();
9798

99+
for i in 1..a_paths.COUNT loop
100+
l_paths := l_paths multiset union ut_utils.string_to_table(a_string => a_paths(i),a_delimiter => ',');
101+
end loop;
102+
98103
ut_console_reporter_base.set_color_enabled(a_color_console);
99104
if a_reporters is null or a_reporters.count = 0 then
100105
ut_event_manager.add_listener(ut_documentation_reporter());
@@ -107,7 +112,7 @@ create or replace package body ut_runner is
107112
if a_coverage_schemes is not empty then
108113
l_coverage_schema_names := ut_utils.convert_collection(a_coverage_schemes);
109114
else
110-
l_coverage_schema_names := ut_suite_manager.get_schema_names(a_paths);
115+
l_coverage_schema_names := ut_suite_manager.get_schema_names(l_paths);
111116
end if;
112117

113118
if a_exclude_objects is not empty then
@@ -119,8 +124,8 @@ create or replace package body ut_runner is
119124
l_include_object_names := to_ut_object_list(a_include_objects, l_coverage_schema_names);
120125

121126
l_run := ut_run(
122-
ut_suite_manager.configure_execution_by_path(a_paths),
123-
a_paths,
127+
ut_suite_manager.configure_execution_by_path(l_paths),
128+
l_paths,
124129
l_coverage_schema_names,
125130
l_exclude_object_names,
126131
l_include_object_names,

test/api/test_ut_run.pkb

Lines changed: 0 additions & 230 deletions
Original file line numberDiff line numberDiff line change
@@ -203,236 +203,6 @@ end;]';
203203
execute immediate 'drop package invalid_pckag_that_revalidates';
204204
execute immediate 'drop package parent_specs';
205205
end;
206-
207-
procedure create_test_csl_packages is
208-
pragma autonomous_transaction;
209-
begin
210-
execute immediate q'[
211-
create or replace package test_csl_names1 as
212-
--%suite
213-
--%suitepath(test_csl_names)
214-
215-
--%test
216-
procedure one_is_one;
217-
218-
--%test
219-
procedure two_is_two;
220-
221-
end;
222-
]';
223-
224-
execute immediate q'{
225-
create or replace package body test_csl_names1 as
226-
227-
procedure one_is_one is
228-
begin
229-
ut3.ut.expect(1).to_equal(1);
230-
end;
231-
232-
procedure two_is_two is
233-
begin
234-
ut3.ut.expect(2).to_equal(2);
235-
end;
236-
237-
end;
238-
}';
239-
240-
execute immediate q'[
241-
create or replace package test_csl_names2 as
242-
--%suite
243-
--%suitepath(test_csl_names)
244-
245-
--%test
246-
procedure one_is_one;
247-
248-
--%test
249-
procedure two_is_two;
250-
251-
end;
252-
]';
253-
254-
execute immediate q'{
255-
create or replace package body test_csl_names2 as
256-
257-
procedure one_is_one is
258-
begin
259-
ut3.ut.expect(1).to_equal(1);
260-
end;
261-
262-
procedure two_is_two is
263-
begin
264-
ut3.ut.expect(2).to_equal(2);
265-
end;
266-
267-
end;
268-
}';
269-
270-
end;
271-
272-
procedure drop_test_csl_packages is
273-
pragma autonomous_transaction;
274-
begin
275-
execute immediate 'drop package test_csl_names1';
276-
execute immediate 'drop package test_csl_names2';
277-
end;
278-
279-
procedure pass_varchar2_name_list is
280-
l_results ut3.ut_varchar2_list;
281-
l_actual clob;
282-
begin
283-
select *
284-
bulk collect into l_results
285-
from table(ut3.ut.run(ut3.ut_varchar2_list('test_csl_names1','test_csl_names2')));
286-
287-
l_actual := ut3.ut_utils.table_to_clob(l_results);
288-
ut.expect(l_actual).to_be_like('%Finished in % seconds
289-
%4 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%');
290-
end;
291-
292-
procedure pass_varchar2_name is
293-
l_results ut3.ut_varchar2_list;
294-
l_actual clob;
295-
begin
296-
select *
297-
bulk collect into l_results
298-
from table(ut3.ut.run('test_csl_names1'));
299-
300-
l_actual := ut3.ut_utils.table_to_clob(l_results);
301-
ut.expect(l_actual).to_be_like('%Finished in % seconds
302-
%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%');
303-
end;
304-
305-
procedure pass_varchar2_suite_csl is
306-
l_results ut3.ut_varchar2_list;
307-
l_actual clob;
308-
begin
309-
select *
310-
bulk collect into l_results
311-
from table(ut3.ut.run('test_csl_names1,test_csl_names2'));
312-
313-
l_actual := ut3.ut_utils.table_to_clob(l_results);
314-
ut.expect(l_actual).to_be_like('%Finished in % seconds
315-
%4 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%');
316-
end;
317-
318-
procedure pass_varchar2_test_csl is
319-
l_results ut3.ut_varchar2_list;
320-
l_actual clob;
321-
begin
322-
select *
323-
bulk collect into l_results
324-
from table(ut3.ut.run('test_csl_names1.one_is_one,test_csl_names2.one_is_one'));
325-
326-
l_actual := ut3.ut_utils.table_to_clob(l_results);
327-
ut.expect(l_actual).to_be_like('%Finished in % seconds
328-
%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%');
329-
end;
330-
331-
procedure pass_varch_test_csl_spc is
332-
l_results ut3.ut_varchar2_list;
333-
l_actual clob;
334-
begin
335-
select *
336-
bulk collect into l_results
337-
from table(ut3.ut.run('test_csl_names1.one_is_one, test_csl_names2.one_is_one'));
338-
339-
l_actual := ut3.ut_utils.table_to_clob(l_results);
340-
ut.expect(l_actual).to_be_like('%Finished in % seconds
341-
%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%');
342-
end;
343-
344-
procedure pass_csl_with_srcfile is
345-
l_results ut3.ut_varchar2_list;
346-
l_actual clob;
347-
begin
348-
349-
select *
350-
bulk collect into l_results
351-
from table(
352-
ut3.ut.run(
353-
a_path => 'test_csl_names1.one_is_one,test_csl_names2.one_is_one',
354-
a_source_files => ut3.ut_varchar2_list('ut3.ut'),
355-
a_test_files => ut3.ut_varchar2_list('ut3_tester.test_csl_names2')
356-
)
357-
);
358-
359-
l_actual := ut3.ut_utils.table_to_clob(l_results);
360-
ut.expect(l_actual).to_be_like('%Finished in % seconds
361-
%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%');
362-
end;
363-
364-
procedure pass_singlevar_with_proc is
365-
l_output_data dbms_output.chararr;
366-
l_num_lines integer := 100000;
367-
l_packages_executed integer := 0;
368-
begin
369-
--act
370-
ut3.ut.run('test_csl_names1');
371-
dbms_output.get_lines( l_output_data, l_num_lines);
372-
373-
for i in 1 .. l_num_lines loop
374-
if l_output_data(i) like '%test_csl_names1%' then
375-
l_packages_executed := l_packages_executed + 1;
376-
end if;
377-
end loop;
378-
ut.expect(l_packages_executed ).to_equal(1);
379-
end;
380-
381-
procedure pass_vlist_with_proc is
382-
l_output_data dbms_output.chararr;
383-
l_num_lines integer := 100000;
384-
l_packages_executed integer := 0;
385-
begin
386-
--act
387-
ut3.ut.run(ut3.ut_varchar2_list('test_csl_names1','test_csl_names2'));
388-
dbms_output.get_lines( l_output_data, l_num_lines);
389-
390-
for i in 1 .. l_num_lines loop
391-
if l_output_data(i) like '%test_csl_names1%'
392-
or l_output_data(i) like '%test_csl_names2%' then
393-
l_packages_executed := l_packages_executed + 1;
394-
end if;
395-
end loop;
396-
ut.expect(l_packages_executed ).to_equal(2);
397-
end;
398-
399-
procedure pass_csl_with_proc is
400-
l_output_data dbms_output.chararr;
401-
l_num_lines integer := 100000;
402-
l_packages_executed integer := 0;
403-
begin
404-
--act
405-
ut3.ut.run('test_csl_names1,test_csl_names2');
406-
dbms_output.get_lines( l_output_data, l_num_lines);
407-
408-
for i in 1 .. l_num_lines loop
409-
if l_output_data(i) like '%test_csl_names1%'
410-
or l_output_data(i) like '%test_csl_names2%' then
411-
l_packages_executed := l_packages_executed + 1;
412-
end if;
413-
end loop;
414-
ut.expect(l_packages_executed ).to_equal(2);
415-
end;
416-
417-
procedure pass_csl_src_proc is
418-
l_output_data dbms_output.chararr;
419-
l_num_lines integer := 100000;
420-
l_packages_executed integer := 0;
421-
begin
422-
--act
423-
ut3.ut.run(a_path => 'test_csl_names1,test_csl_names2',
424-
a_source_files => ut3.ut_varchar2_list('ut3.ut'),
425-
a_test_files => ut3.ut_varchar2_list('ut3_tester.test_csl_names2'));
426-
dbms_output.get_lines( l_output_data, l_num_lines);
427-
428-
for i in 1 .. l_num_lines loop
429-
if l_output_data(i) like '%test_csl_names1%'
430-
or l_output_data(i) like '%test_csl_names2%' then
431-
l_packages_executed := l_packages_executed + 1;
432-
end if;
433-
end loop;
434-
ut.expect(l_packages_executed ).to_equal(2);
435-
end;
436206

437207
end;
438208
/

test/api/test_ut_run.pks

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,45 +22,6 @@ create or replace package test_ut_run is
2222
procedure run_and_revalidate_specs;
2323
procedure generate_invalid_spec;
2424
procedure drop_test_package;
25-
26-
procedure create_test_csl_packages;
27-
procedure drop_test_csl_packages;
28-
29-
--%context(ut_run_coma_sep_list)
30-
--%beforeall(create_test_csl_packages)
31-
--%afterall(drop_test_csl_packages)
32-
33-
--%test( Pass name of tests as varchar2_list )
34-
procedure pass_varchar2_name_list;
35-
36-
--%test( Pass single test name as varchar2 )
37-
procedure pass_varchar2_name;
38-
39-
--%test( Pass coma separated list of suite names )
40-
procedure pass_varchar2_suite_csl;
41-
42-
--%test( Pass coma separated list of test names )
43-
procedure pass_varchar2_test_csl;
44-
45-
--%test( Pass coma separated list of test names with spaces )
46-
procedure pass_varch_test_csl_spc;
47-
48-
--%test( Pass coma separated list and source and test files )
49-
procedure pass_csl_with_srcfile;
50-
51-
--%test( Pass single varchar2 into procedure )
52-
procedure pass_singlevar_with_proc;
53-
54-
--%test( Pass varchar2_list into procedure )
55-
procedure pass_vlist_with_proc;
56-
57-
--%test( Pass coma separated list varchar2 into procedure )
58-
procedure pass_csl_with_proc;
59-
60-
--%test( Pass coma separated list varchar2 into procedure with src file)
61-
procedure pass_csl_src_proc;
62-
63-
--%endcontext
64-
25+
6526
end;
6627
/

0 commit comments

Comments
 (0)