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

Skip to content

Commit 773eae2

Browse files
committed
Improved functionality of reporters to allow for inline calls.
References #955
1 parent 1ea69d8 commit 773eae2

3 files changed

Lines changed: 65 additions & 3 deletions

File tree

docs/userguide/running-unit-tests.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ curl -Lk "${DOWNLOAD_URL}" -o utplsql-cli.zip
3131
unzip -q utplsql-cli.zip
3232
```
3333

34+
Keep in mind that you will need to download/provide Oracle JDBC driver separately, as it is not part of utPLSQL-cli due to licensing restrictions.
35+
3436
# ut.run
3537

3638
The `ut` package contains overloaded `run` procedures and functions.
@@ -167,11 +169,63 @@ The main difference compared to the `ut.run` API is that `ut_runner.run` does no
167169
`ut_runner.run` accepts multiple reporters. Each reporter pipes to a separate output (uniquely identified by output_id).
168170
Outputs of multiple reporters can be consumed in parallel. This allows for live reporting of test execution progress with threads and several database sessions.
169171

170-
The concept is pretty simple.
172+
`ut_runner.run` API is used by utPLSQL-cli, utPLSQL-SQLDeveloper extension and utPLSQL-maven-plugin and allows for:
173+
- deciding on the scope of test run (by schema names, object names, suite paths or tags )
174+
- running tests with several concurrent reporters
175+
- real-time reporting of test execution progress
176+
- controlling colored text output to the screen
177+
- controlling scope of code coverage reports
178+
- mapping of database source code to project files
179+
- controlling behavior on test-failures
180+
- controlling client character set for HTML and XML reports
181+
- controlling rollback behavior of test-run
182+
- controlling random order of test execution
183+
184+
Running with multiple reporters.
171185

172186
- in the main thread (session), define the reporters to be used. Each reporter has it's output_id and so you need to extract and store those output_ids.
173187
- as a separate thread, start `ut_runner.run` and pass reporters with previously defined output_ids.
174-
- for each reporter start a separate thread and read outputs from the `ut_output_buffer.get_lines` table function by providing the output_id defined in the main thread.
188+
- for each reporter start a separate thread and read outputs from the `reporter.get_lines` table function or from `reporter.get_lines_cursor()` by providing the `reporter_id` defined in the main thread.
189+
- each reporter for each test-run must have a unique `reporter_id`. The `reporter_id` is used between two sessions to identify the data stream
190+
191+
Example:
192+
```sql
193+
--main test run ( session 1 )
194+
declare
195+
l_reporter ut_realtime_reporter := ut_realtime_reporter();
196+
begin
197+
l_reporter.set_reporter_id( 'd8a79e85915640a6a4e1698fdf90ba74' );
198+
l_reporter.output_buffer.init();
199+
ut_runner.run (ut_varchar2_list ('ut3_tester','ut3$user#'), ut_reporters( l_reporter ) );
200+
end;
201+
/
202+
```
203+
204+
```sql
205+
--report consumer ( session 2 )
206+
set arraysize 1
207+
set pagesize 0
208+
209+
select *
210+
from table(
211+
ut_realtime_reporter()
212+
.set_reporter_id('d8a79e85915640a6a4e1698fdf90ba74')
213+
.get_lines()
214+
);
215+
```
216+
217+
```sql
218+
--alternative version of report consumer ( session 2 )
219+
set arraysize 1
220+
set pagesize 0
221+
222+
select
223+
ut_realtime_reporter()
224+
.set_reporter_id('d8a79e85915640a6a4e1698fdf90ba74')
225+
.get_lines_cursor()
226+
from dual;
227+
```
228+
175229

176230
# Order of test execution
177231

source/core/types/ut_output_reporter_base.tpb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@ create or replace type body ut_output_reporter_base is
3131
overriding member procedure set_reporter_id(self in out nocopy ut_output_reporter_base, a_reporter_id raw) is
3232
begin
3333
self.id := a_reporter_id;
34-
self.output_buffer.output_id := a_reporter_id;
34+
self.output_buffer.init(a_reporter_id);
35+
end;
36+
37+
member function set_reporter_id(self in ut_output_reporter_base, a_reporter_id raw) return ut_output_reporter_base is
38+
l_result ut_output_reporter_base := self;
39+
begin
40+
l_result.set_reporter_id(a_reporter_id);
41+
return l_result;
3542
end;
3643

3744
overriding member procedure before_calling_run(self in out nocopy ut_output_reporter_base, a_run in ut_run) is

source/core/types/ut_output_reporter_base.tps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ create or replace type ut_output_reporter_base under ut_reporter_base(
1919
constructor function ut_output_reporter_base(self in out nocopy ut_output_reporter_base) return self as result,
2020
member procedure init(self in out nocopy ut_output_reporter_base, a_self_type varchar2, a_output_buffer ut_output_buffer_base := null),
2121
overriding member procedure set_reporter_id(self in out nocopy ut_output_reporter_base, a_reporter_id raw),
22+
member function set_reporter_id(self in ut_output_reporter_base, a_reporter_id raw) return ut_output_reporter_base,
2223
overriding member procedure before_calling_run(self in out nocopy ut_output_reporter_base, a_run in ut_run),
2324

2425
member procedure print_text(self in out nocopy ut_output_reporter_base, a_text varchar2, a_item_type varchar2 := null),

0 commit comments

Comments
 (0)