Skip to content

fixed failed expectation source code line reporting because 12c repor… #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions source/core/ut_expectation_processor.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ create or replace package body ut_expectation_processor as
l_caller_type_and_name varchar2(4000);
l_line_no integer;
l_owner varchar2(1000);
l_object_name varchar2(1000);
c_expectation_search_pattern constant varchar2(50) := '(.*\.UT_EXPECTATION[A-Z0-9#_$]*\s)+(.*)\s';
l_object_name varchar2(1000);
-- in 12.2 format_call_stack reportes not only package name, but also the procedure name
-- when 11g and 12c reports only package name
c_expectation_search_pattern constant varchar2(500) := '(.*\.UT_EXPECTATION_RESULT\s+)(.*\.UT_EXPECTATION[A-Z0-9#_$]*(\.\w+)?.*\s+)+(.*)\s';
begin
l_caller_stack_line := regexp_substr( c_call_stack, c_expectation_search_pattern, 1, 1, 'm', 2);
l_caller_stack_line := regexp_substr( c_call_stack, c_expectation_search_pattern, 1, 1, 'm', 4);
l_line_no := to_number( regexp_substr(l_caller_stack_line,'^\dx[0-9a-f]+\s+(\d+)',subexpression => 1) );
l_caller_type_and_name := substr( l_caller_stack_line, 23 );
if l_caller_stack_line like '%.%' then
Expand Down
1 change: 1 addition & 0 deletions tests/RunAll.sql
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ exec ut_coverage.coverage_start_develop();

@@lib/RunTest.sql ut_reporters/ut_coverage_sonar_reporter.AcceptsFileMapping.sql
@@lib/RunTest.sql ut_reporters/ut_coverage_sonar_reporter.BuildsSonarCoverageReport.sql
@@lib/RunTest.sql ut_reporters/ut_documentation_reporter.providesCorrectLineFromStacktrace.sql
@@lib/RunTest.sql ut_reporters/ut_sonar_test_reporter.AcceptsFileMapping.sql
@@lib/RunTest.sql ut_reporters/ut_sonar_test_reporter.ProducesExpectedOutputs.sql
@@lib/RunTest.sql ut_reporters/ut_teamcity_reporter.ProducesExpectedOutputs.sql
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
declare
l_output_data ut_varchar2_list;
l_output varchar2(32767);
l_expected varchar2(32767);
begin
l_expected := q'[%<!beforeall!>
%passing_test
%<!beforeeach!>
%<!beforetest!>
%<!passing test!>
%<!aftertest!>
%<!aftereach!>
%a test with failing assertion (FAILED - 1)
%<!beforeeach!>
%<!failing test!>
%<!aftereach!>
%a test raising unhandled exception (FAILED - 2)
%<!beforeeach!>
%<!erroring test!>
%<!aftereach!>
%a disabled test (IGNORED)
%<!afterall!>
%Failures:%
%1)%failing_test
%"Fails as values are different"
%Actual: 1 (number) was expected to equal: 2 (number)
%at "%.TEST_REPORTERS%", line%
%2)%erroring_test
%ORA-06502%
%ORA-06512%
Finished %
4 tests, 1 failed, 1 errored%]';

--act
select *
bulk collect into l_output_data
from table(ut.run('test_reporters',ut_documentation_reporter()));

l_output := ut_utils.table_to_clob(l_output_data);

--assert
if l_output like l_expected then
:test_result := ut_utils.tr_success;
else
dbms_output.put_line('Actual:"'||l_output||'"');
end if;
end;
/