-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(it): Add integration tests for test and coverage reports
- Loading branch information
Showing
5 changed files
with
194 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
sonar-zpa-plugin/src/integrationTest/resources/projects/metrics/coverage.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<coverage version="1"> | ||
<file path="function ut3_demo.betwnstr"> | ||
<lineToCover lineNumber="2" covered="true"/> | ||
<lineToCover lineNumber="4" covered="true"/> | ||
<lineToCover lineNumber="5" covered="true"/> | ||
<lineToCover lineNumber="7" covered="true"/> | ||
</file> | ||
</coverage> |
9 changes: 9 additions & 0 deletions
9
sonar-zpa-plugin/src/integrationTest/resources/projects/metrics/src/betwnstr.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE OR REPLACE FUNCTION BETWNSTR(A_STRING VARCHAR2, A_START_POS INTEGER, A_END_POS INTEGER) RETURN VARCHAR2 IS | ||
L_START_POS PLS_INTEGER := A_START_POS; | ||
BEGIN | ||
IF L_START_POS = 0 THEN | ||
L_START_POS := 1; | ||
END IF; | ||
RETURN SUBSTR(A_STRING, L_START_POS, A_END_POS - L_START_POS + 1); | ||
END; | ||
/ |
67 changes: 67 additions & 0 deletions
67
sonar-zpa-plugin/src/integrationTest/resources/projects/metrics/test/test_betwnstr.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
create or replace package test_betwnstr as | ||
-- %suite(Between string function) | ||
|
||
-- %test(Returns substring from start position to end position) | ||
procedure normal_case; | ||
|
||
-- %test(Returns substring when start position is zero) | ||
procedure zero_start_position; | ||
|
||
-- %test(Returns string until end if end position is greater than string length) | ||
procedure big_end_position; | ||
|
||
-- %test(Returns null for null input string value) | ||
procedure null_string; | ||
|
||
-- %test(A demo of test raising runtime exception) | ||
procedure bad_params; | ||
|
||
-- %test(A demo of failing test) | ||
procedure bad_test; | ||
|
||
-- %test(Demo of a disabled test) | ||
-- %disabled | ||
procedure disabled_test; | ||
|
||
end; | ||
/ | ||
create or replace package body test_betwnstr as | ||
|
||
procedure normal_case is | ||
begin | ||
ut.expect(betwnstr('1234567', 2, 5)).to_equal('2345'); | ||
end; | ||
|
||
procedure zero_start_position is | ||
begin | ||
ut.expect(betwnstr('1234567', 0, 5)).to_(equal('12345')); | ||
end; | ||
|
||
procedure big_end_position is | ||
begin | ||
ut.expect(betwnstr('1234567', 0, 500)).to_(equal('1234567')); | ||
end; | ||
|
||
procedure null_string is | ||
begin | ||
ut.expect(betwnstr(null, 2, 5)).to_(be_null()); | ||
end; | ||
|
||
procedure bad_params is | ||
begin | ||
ut.expect(betwnstr('1234567', 'a', 'b')).to_(be_null()); | ||
end; | ||
|
||
procedure bad_test | ||
is | ||
begin | ||
ut.expect(betwnstr('1234567', 0, 500)).to_(equal('1')); | ||
end; | ||
|
||
procedure disabled_test is | ||
begin | ||
ut.expect(betwnstr(null, null, null)).not_to(be_null); | ||
end; | ||
|
||
end; | ||
/ |
34 changes: 34 additions & 0 deletions
34
sonar-zpa-plugin/src/integrationTest/resources/projects/metrics/test_results.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<testExecutions version="1"> | ||
<file path="test_betwnstr"> | ||
<testCase name="normal_case" duration="2"> | ||
</testCase> | ||
<testCase name="zero_start_position" duration="2"> | ||
</testCase> | ||
<testCase name="big_end_position" duration="2"> | ||
</testCase> | ||
<testCase name="null_string" duration="2"> | ||
</testCase> | ||
<testCase name="bad_params" duration="2"> | ||
<error message="encountered errors"> | ||
<![CDATA[ | ||
ORA-06502: PL/SQL: erro: erro de conversão de caractere em número numérico ou de valor | ||
ORA-06512: em "UT3_DEMO.TEST_BETWNSTR", line 25 | ||
ORA-06512: em "UT3_DEMO.TEST_BETWNSTR", line 25 | ||
ORA-06512: em line 6 | ||
]]> | ||
</error> | ||
</testCase> | ||
<testCase name="bad_test" duration="5"> | ||
<failure message="some expectations have failed"> | ||
<![CDATA[ | ||
Actual: '1234567' (varchar2) was expected to equal: '1' (varchar2) | ||
at "UT3_DEMO.TEST_BETWNSTR.BAD_TEST", line 31 ut.expect( betwnstr( '1234567', 0, 500 ) ).to_( equal('1') ); | ||
]]> | ||
</failure> | ||
</testCase> | ||
<testCase name="disabled_test" duration="0"> | ||
<skipped message="skipped"/> | ||
</testCase> | ||
</file> | ||
</testExecutions> |