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

Skip to content

Commit 132a82a

Browse files
committed
Added all_expectations as an attribute for ut_test class.
Removed `expectations_count` as it can now be obtained from `all_expectations.count` `ut_expectation_processor` now holds all expectation results. `ut_test` is nor responsible for clearing the state of `ut_expectation_processor` after reading expectations results.
1 parent 9b6cbeb commit 132a82a

5 files changed

Lines changed: 22 additions & 11 deletions

File tree

source/core/types/ut_test.tpb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,21 @@ create or replace type body ut_test as
3030
self.item := ut_executable(self, a_name, ut_utils.gc_test_execute);
3131
self.after_test := ut_executable(self, a_after_test_proc_name, ut_utils.gc_after_test);
3232
self.after_each := ut_executable(self, a_after_each_proc_name, ut_utils.gc_after_each);
33+
self.all_expectations := ut_expectation_results();
34+
self.failed_expectations := ut_expectation_results();
3335
return;
3436
end;
3537

3638
member procedure set_beforeeach(self in out nocopy ut_test, a_before_each_proc_name varchar2) is
3739
begin
3840
self.before_each := ut_executable(self, a_before_each_proc_name, ut_utils.gc_before_each);
3941
end;
42+
4043
member procedure set_aftereach(self in out nocopy ut_test, a_after_each_proc_name varchar2) is
4144
begin
4245
self.after_each := ut_executable(self, a_after_each_proc_name, ut_utils.gc_after_each);
4346
end;
47+
4448
member function is_valid(self in out nocopy ut_test) return boolean is
4549
l_is_valid boolean;
4650
begin
@@ -114,8 +118,9 @@ create or replace type body ut_test as
114118
self.result := ut_utils.tr_error;
115119
end if;
116120
--expectation results need to be part of test results
117-
self.expectations_count := ut_expectation_processor.get_expectations_count();
121+
self.all_expectations := ut_expectation_processor.get_all_expectations();
118122
self.failed_expectations := ut_expectation_processor.get_failed_expectations();
123+
ut_expectation_processor.clear_expectations();
119124
self.results_count.set_counter_values(self.result);
120125
end;
121126

source/core/types/ut_test.tps

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,20 @@ create or replace type ut_test under ut_suite_item (
4040
*/
4141
after_each ut_executable,
4242
/**
43-
* The list of failed expectation results as well as database errors encountered while invoking
44-
* The test procedure and the before_test/after_test blocks
43+
* The list of all expectations results as well as database errors encountered while invoking
44+
* the test procedure and the before_test/after_test blocks
45+
*/
46+
all_expectations ut_expectation_results,
47+
48+
/**
49+
* The list of failed expectations results as well as database errors encountered while invoking
50+
* the test procedure and the before_test/after_test blocks
4551
*/
4652
failed_expectations ut_expectation_results,
4753
/**
48-
* The count of all expectations executed in the test
54+
* Holds information about error stacktrace from parent execution (suite)
55+
* Will get populated on exceptions in before-all calls
4956
*/
50-
expectations_count integer,
5157
parent_error_stack_trace varchar2(4000),
5258
constructor function ut_test(
5359
self in out nocopy ut_test, a_object_owner varchar2 := null, a_object_name varchar2, a_name varchar2, a_description varchar2 := null,

source/core/ut_expectation_processor.pkb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ create or replace package body ut_expectation_processor as
5252
g_expectations_called.delete;
5353
end;
5454

55-
function get_expectations_count return integer is
55+
function get_all_expectations return ut_expectation_results is
5656
begin
57-
return g_expectations_called.count;
58-
end;
57+
ut_utils.debug_log('ut_expectation_processor.get_all_expectations: g_expectations_called.count='||g_expectations_called.count);
58+
return g_expectations_called;
59+
end get_all_expectations;
5960

6061
function get_failed_expectations return ut_expectation_results is
6162
l_expectations_results ut_expectation_results := ut_expectation_results();
@@ -68,7 +69,6 @@ create or replace package body ut_expectation_processor as
6869
end if;
6970
end loop;
7071
ut_utils.debug_log('ut_expectation_processor.get_failed_expectations: l_expectations_results.count='||g_expectations_called.count);
71-
clear_expectations();
7272
return l_expectations_results;
7373
end get_failed_expectations;
7474

source/core/ut_expectation_processor.pks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ create or replace package ut_expectation_processor authid current_user as
2828

2929
procedure clear_expectations;
3030

31-
function get_expectations_count return integer;
31+
function get_all_expectations return ut_expectation_results;
3232

3333
function get_failed_expectations return ut_expectation_results;
3434

source/reporters/ut_xunit_reporter.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ create or replace type body ut_xunit_reporter is
3737
l_output clob;
3838
begin
3939
self.print_text('<testcase classname="' || dbms_xmlgen.convert(get_path(a_test.path, a_test.name)) || '" ' || ' assertions="' ||
40-
nvl(a_test.expectations_count,0) || '"' || self.get_common_item_attributes(a_test) || case when
40+
nvl(a_test.all_expectations.count,0) || '"' || self.get_common_item_attributes(a_test) || case when
4141
a_test.result != ut_utils.tr_success then
4242
' status="' || ut_utils.test_result_to_char(a_test.result) || '"' end || '>');
4343
if a_test.result = ut_utils.tr_disabled then

0 commit comments

Comments
 (0)