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

Skip to content

Commit 9c8ddcc

Browse files
authored
Merge branch 'develop' into bugfix/sonar_test_reporter
2 parents 2c3df8b + 8b509c7 commit 9c8ddcc

6 files changed

Lines changed: 103 additions & 8 deletions

File tree

mkdocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# http://www.mkdocs.org/user-guide/configuration/
33

44
site_name: utPLSQL
5-
site_description: utPLSQL Documenation Powerful Unit Testing Framework for Oracle PL/SQL
5+
site_description: utPLSQL Ultimate Unit Testing Framework for Oracle PL/SQL
66
copyright: Copyright © 2016 - 2018 utPLSQL Team
77
repo_url: https://github.com/utPLSQL/utPLSQL
88
theme: mkdocs
99
use_directory_urls: false
1010
strict: true
1111

12-
pages:
12+
nav:
1313
- Home: index.md
1414
- User Guide:
1515
- Installation: userguide/install.md

source/core/ut_utils.pks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ create or replace package ut_utils authid definer is
2121
*
2222
*/
2323

24-
gc_version constant varchar2(50) := 'v3.1.3.2195-develop';
24+
gc_version constant varchar2(50) := 'v3.1.3.2212-develop';
2525

2626
/* Constants: Event names */
2727
subtype t_event_name is varchar2(30);

source/reporters/ut_teamcity_reporter_helper.pkb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ create or replace package body ut_teamcity_reporter_helper is
2121

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

2727
function message(a_command in varchar2, a_props t_props default cast(null as t_props)) return varchar2 is
2828
l_message varchar2(32767);
2929
l_index t_prop_index;
3030
l_value varchar2(32767);
31+
l_max_len binary_integer := 2000;
3132
begin
3233
l_message := '##teamcity[' || a_command || ' timestamp=''' ||
3334
regexp_replace(to_char(systimestamp, 'YYYY-MM-DD"T"HH24:MI:ss.FF3TZHTZM'), '(\.\d{3})\d+(\+)', '\1\2') || '''';
@@ -36,6 +37,9 @@ create or replace package body ut_teamcity_reporter_helper is
3637
while l_index is not null loop
3738
if a_props(l_index) is not null then
3839
l_value := escape_value(a_props(l_index));
40+
if length(l_value) > l_max_len then
41+
l_value := substr(l_value,1,l_max_len-7)||escape_value('[...]');
42+
end if;
3943
l_message := l_message || ' ' || l_index || '=''' || l_value || '''';
4044
end if;
4145
l_index := a_props.next(l_index);

test/core/reporters.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ as
8181
is
8282
begin
8383
dbms_output.put_line('<!failing test!>');
84-
ut3.ut.expect(1,'Fails as values are different').to_equal(2);
84+
ut3.ut.expect('number [1] ','Fails as values are different').to_equal('number [2] ');
8585
end;
8686

8787
procedure erroring_test

test/core/reporters/test_teamcity_reporter.pkb

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
create or replace package body test_teamcity_reporter as
22

3+
procedure create_a_test_package is
4+
pragma autonomous_transaction;
5+
begin
6+
execute immediate q'[create or replace package check_escape_special_chars is
7+
--%suite(A suite with 'quote')
8+
9+
--%test(A test with 'quote')
10+
procedure test_do_stuff;
11+
12+
end;]';
13+
execute immediate q'[create or replace package body check_escape_special_chars is
14+
procedure test_do_stuff is
15+
begin
16+
ut3.ut.expect(' [ ' || chr(13) || chr(10) || ' ] ' ).to_be_null;
17+
end;
18+
19+
end;]';
20+
21+
execute immediate q'[create or replace package check_trims_long_output is
22+
--%suite
23+
24+
--%test
25+
procedure long_output;
26+
end;]';
27+
execute immediate q'[create or replace package body check_trims_long_output is
28+
procedure long_output is
29+
begin
30+
ut3.ut.expect(rpad('aVarchar',4000,'a')).to_be_null;
31+
end;
32+
end;]';
33+
34+
end;
35+
36+
337
procedure report_produces_expected_out is
438
l_output_data ut3.ut_varchar2_list;
539
l_output clob;
@@ -23,14 +57,14 @@ create or replace package body test_teamcity_reporter as
2357
<!beforeeach!>
2458
<!failing test!>
2559
<!aftereach!>
26-
%##teamcity[testFailed timestamp='%' message='Fails as values are different' name='ut3_tester.test_reporters.failing_test']
60+
%##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']
2761
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.test_reporters.failing_test']
2862
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.erroring_test']
2963
<!beforeeach!>
3064
<!erroring test!>
3165
<!aftereach!>
32-
%##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']
33-
%##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']
66+
%##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']
67+
%##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']
3468
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.test_reporters.erroring_test']
3569
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.disabled_test']
3670
%##teamcity[testIgnored timestamp='%' name='ut3_tester.test_reporters.disabled_test']
@@ -48,5 +82,50 @@ create or replace package body test_teamcity_reporter as
4882
ut.expect(ut3.ut_utils.table_to_clob(l_output_data)).to_be_like(l_expected);
4983
end;
5084

85+
procedure escape_special_chars is
86+
l_output_data ut3.ut_varchar2_list;
87+
l_output clob;
88+
l_expected varchar2(32767);
89+
begin
90+
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='A suite with |'quote|'']
91+
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.check_escape_special_chars.test_do_stuff']
92+
%##teamcity[testFailed timestamp='%' details='Actual: (varchar2)|n |' |[ |r|n |] |'|nwas expected to be null' name='ut3_tester.check_escape_special_chars.test_do_stuff']
93+
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.check_escape_special_chars.test_do_stuff']
94+
%##teamcity[testSuiteFinished timestamp='%' name='A suite with |'quote|'']}';
95+
--act
96+
select *
97+
bulk collect into l_output_data
98+
from table(ut3.ut.run('check_escape_special_chars',ut3.ut_teamcity_reporter()));
99+
100+
--assert
101+
ut.expect(ut3.ut_utils.table_to_clob(l_output_data)).to_be_like(l_expected);
102+
end;
103+
104+
procedure trims_long_output is
105+
l_output_data ut3.ut_varchar2_list;
106+
l_output clob;
107+
l_expected varchar2(32767);
108+
begin
109+
l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='check_trims_long_output']
110+
%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.check_trims_long_output.long_output']
111+
%##teamcity[testFailed timestamp='%' details='Actual: (varchar2)|n |'aVarcharaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|[...|]' name='ut3_tester.check_trims_long_output.long_output']
112+
%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.check_trims_long_output.long_output']
113+
%##teamcity[testSuiteFinished timestamp='%' name='check_trims_long_output']}';
114+
--act
115+
select *
116+
bulk collect into l_output_data
117+
from table(ut3.ut.run('check_trims_long_output',ut3.ut_teamcity_reporter()));
118+
119+
--assert
120+
ut.expect(ut3.ut_utils.table_to_clob(l_output_data)).to_be_like(l_expected);
121+
end;
122+
123+
procedure remove_test_package is
124+
pragma autonomous_transaction;
125+
begin
126+
execute immediate 'drop package check_escape_special_chars';
127+
execute immediate 'drop package check_trims_long_output';
128+
end;
129+
51130
end;
52131
/

test/core/reporters/test_teamcity_reporter.pks

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,20 @@ create or replace package test_teamcity_reporter as
33
--%suite(ut_teamcity_reporter)
44
--%suitepath(utplsql.core.reporters)
55

6+
--%beforeall
7+
procedure create_a_test_package;
8+
69
--%test(Report produces expected output)
710
procedure report_produces_expected_out;
811

12+
--%test(Escapes special characters)
13+
procedure escape_special_chars;
14+
15+
--%test(Trims output so it fits into 4000 chars)
16+
procedure trims_long_output;
17+
18+
--%afterall
19+
procedure remove_test_package;
20+
921
end;
1022
/

0 commit comments

Comments
 (0)