Skip to content

Commit

Permalink
Resolves issues with teamcity reporter:
Browse files Browse the repository at this point in the history
- the `[` and `]` were not escaped
- the `"` was escaped though not needed
- If total length of message inside the square brackets exceeds 4000 characters it's causing teamcity to report success for a test failed
Resolves #747
  • Loading branch information
jgebal committed Aug 11, 2018
1 parent f590d77 commit c850b38
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions source/reporters/ut_teamcity_reporter_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ create or replace package body ut_teamcity_reporter_helper is

function escape_value(a_value in varchar2) return varchar2 is
begin
return translate(regexp_replace(a_value, '(''|"|[|]|' || chr(13) || '|' || chr(10) || ')', '|\1'),chr(13)||chr(10),'nr');
return translate(regexp_replace(a_value, q'/(\'|\||\[|\]|/' || chr(13) || '|' || chr(10) || ')', '|\1'),chr(13)||chr(10),'rn');
end;

function message(a_command in varchar2, a_props t_props default cast(null as t_props)) return varchar2 is
Expand All @@ -35,7 +35,7 @@ create or replace package body ut_teamcity_reporter_helper is
l_index := a_props.first;
while l_index is not null loop
if a_props(l_index) is not null then
l_value := escape_value(a_props(l_index));
l_value := substr(escape_value(a_props(l_index)),1,2000);
l_message := l_message || ' ' || l_index || '=''' || l_value || '''';
end if;
l_index := a_props.next(l_index);
Expand Down
2 changes: 1 addition & 1 deletion test/core/reporters.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ as
is
begin
dbms_output.put_line('<!failing test!>');
ut3.ut.expect(1,'Fails as values are different').to_equal(2);
ut3.ut.expect('number [1] ','Fails as values are different').to_equal('number [2] ');
end;

procedure erroring_test
Expand Down
6 changes: 3 additions & 3 deletions test/core/reporters/test_teamcity_reporter.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ create or replace package body test_teamcity_reporter as
<!beforeeach!>
<!failing test!>
<!aftereach!>
%##teamcity[testFailed timestamp='%' message='Fails as values are different' name='ut3_tester.test_reporters.failing_test']
%##teamcity[testFailed timestamp='%' details='Actual: |'number |[1|] |' (varchar2) was expected to equal: |'number |[2|] |' (varchar2) ' message='Fails as values are different' name='ut3_tester.test_reporters.failing_test']
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.test_reporters.failing_test']
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.erroring_test']
<!beforeeach!>
<!erroring test!>
<!aftereach!>
%##teamcity[testStdErr timestamp='%' name='ut3_tester.test_reporters.erroring_test' out='Test exception:|rORA-06512: at |"UT3_TESTER.TEST_REPORTERS|", line %|rORA-06512: at %|r|r']
%##teamcity[testFailed timestamp='%' details='Test exception:|rORA-06512: at |"UT3_TESTER.TEST_REPORTERS|", line %|rORA-06512: at %|r|r' message='Error occured' name='ut3_tester.test_reporters.erroring_test']
%##teamcity[testStdErr timestamp='%' name='ut3_tester.test_reporters.erroring_test' out='Test exception:|nORA-06512: at "UT3_TESTER.TEST_REPORTERS", line %|nORA-06512: at %|n|n']
%##teamcity[testFailed timestamp='%' details='Test exception:|nORA-06512: at "UT3_TESTER.TEST_REPORTERS", line %|nORA-06512: at %|n|n' message='Error occured' name='ut3_tester.test_reporters.erroring_test']
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.test_reporters.erroring_test']
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.disabled_test']
%##teamcity[testIgnored timestamp='%' name='ut3_tester.test_reporters.disabled_test']
Expand Down

0 comments on commit c850b38

Please sign in to comment.