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

Skip to content

Commit a9ffefa

Browse files
authored
Merge pull request #332 from Pazus/fix-expectation-reporting
fixed failed expectation source code line reporting because 12c repor…
2 parents 1236007 + 1d6da23 commit a9ffefa

3 files changed

Lines changed: 54 additions & 3 deletions

File tree

source/core/ut_expectation_processor.pkb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,12 @@ create or replace package body ut_expectation_processor as
126126
l_caller_type_and_name varchar2(4000);
127127
l_line_no integer;
128128
l_owner varchar2(1000);
129-
l_object_name varchar2(1000);
130-
c_expectation_search_pattern constant varchar2(50) := '(.*\.UT_EXPECTATION[A-Z0-9#_$]*\s)+(.*)\s';
129+
l_object_name varchar2(1000);
130+
-- in 12.2 format_call_stack reportes not only package name, but also the procedure name
131+
-- when 11g and 12c reports only package name
132+
c_expectation_search_pattern constant varchar2(500) := '(.*\.UT_EXPECTATION_RESULT\s+)(.*\.UT_EXPECTATION[A-Z0-9#_$]*(\.\w+)?.*\s+)+(.*)\s';
131133
begin
132-
l_caller_stack_line := regexp_substr( c_call_stack, c_expectation_search_pattern, 1, 1, 'm', 2);
134+
l_caller_stack_line := regexp_substr( c_call_stack, c_expectation_search_pattern, 1, 1, 'm', 4);
133135
l_line_no := to_number( regexp_substr(l_caller_stack_line,'^\dx[0-9a-f]+\s+(\d+)',subexpression => 1) );
134136
l_caller_type_and_name := substr( l_caller_stack_line, 23 );
135137
if l_caller_stack_line like '%.%' then

tests/RunAll.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ exec ut_coverage.coverage_start_develop();
129129

130130
@@lib/RunTest.sql ut_reporters/ut_coverage_sonar_reporter.AcceptsFileMapping.sql
131131
@@lib/RunTest.sql ut_reporters/ut_coverage_sonar_reporter.BuildsSonarCoverageReport.sql
132+
@@lib/RunTest.sql ut_reporters/ut_documentation_reporter.providesCorrectLineFromStacktrace.sql
132133
@@lib/RunTest.sql ut_reporters/ut_sonar_test_reporter.AcceptsFileMapping.sql
133134
@@lib/RunTest.sql ut_reporters/ut_sonar_test_reporter.ProducesExpectedOutputs.sql
134135
@@lib/RunTest.sql ut_reporters/ut_teamcity_reporter.ProducesExpectedOutputs.sql
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
declare
2+
l_output_data ut_varchar2_list;
3+
l_output varchar2(32767);
4+
l_expected varchar2(32767);
5+
begin
6+
l_expected := q'[%<!beforeall!>
7+
%passing_test
8+
%<!beforeeach!>
9+
%<!beforetest!>
10+
%<!passing test!>
11+
%<!aftertest!>
12+
%<!aftereach!>
13+
%a test with failing assertion (FAILED - 1)
14+
%<!beforeeach!>
15+
%<!failing test!>
16+
%<!aftereach!>
17+
%a test raising unhandled exception (FAILED - 2)
18+
%<!beforeeach!>
19+
%<!erroring test!>
20+
%<!aftereach!>
21+
%a disabled test (IGNORED)
22+
%<!afterall!>
23+
%Failures:%
24+
%1)%failing_test
25+
%"Fails as values are different"
26+
%Actual: 1 (number) was expected to equal: 2 (number)
27+
%at "%.TEST_REPORTERS%", line%
28+
%2)%erroring_test
29+
%ORA-06502%
30+
%ORA-06512%
31+
Finished %
32+
4 tests, 1 failed, 1 errored%]';
33+
34+
--act
35+
select *
36+
bulk collect into l_output_data
37+
from table(ut.run('test_reporters',ut_documentation_reporter()));
38+
39+
l_output := ut_utils.table_to_clob(l_output_data);
40+
41+
--assert
42+
if l_output like l_expected then
43+
:test_result := ut_utils.tr_success;
44+
else
45+
dbms_output.put_line('Actual:"'||l_output||'"');
46+
end if;
47+
end;
48+
/

0 commit comments

Comments
 (0)