Skip to content
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

Replaced hard coded 0 in total test coverage #1140

Merged

Conversation

OsBlaineOra
Copy link
Contributor

with covered lines / total total lines.
Rounding to 17 decimal places since that's what I found when looking at cobertura examples online.
Used an rpad to generate the format mask to avoid having a long string of 9s.

This was mentioned in #1107 but does not have an issue of its own.

with covered lines / total  total lines.
Rounding to 17 decimal places since that's what I found when looking at cobertura examples online.
Used an rpad to generate the format mask to avoid having a long string of 9s.

This was mentioned in utPLSQL#1107 but does not have an issue of its own.
I introduced the error in the previous commit.

To fix I added a l_lines_valid variable, used a case statement to check for 0 else return the calculation.
I also replaced the lines_valid calculation to use the new variable to reduce code duplication.
c_lines_footer constant varchar2(30) := '</lines>';
l_epoch varchar2(50) := (sysdate - to_date('01-01-1970 00:00:00', 'dd-mm-yyyy hh24:mi:ss')) * 24 * 60 * 60;
l_lines_valid number := a_coverage_data.covered_lines + a_coverage_data.uncovered_lines;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

integer will be better, as the lines are always integer

||a_coverage_data.covered_lines||'" lines-valid="'
||TO_CHAR(a_coverage_data.covered_lines + a_coverage_data.uncovered_lines)
||TO_CHAR(l_lines_valid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make this TO_CHAR lowercase since you've touched this line?

@@ -90,9 +91,11 @@ create or replace type body ut_coverage_cobertura_reporter is
--write header
ut_utils.append_to_list(
l_result,
'<coverage line-rate="0" branch-rate="0.0" lines-covered="'
'<coverage line-rate="'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice small fix. Love it!

@jgebal
Copy link
Member

jgebal commented Oct 28, 2021

Thank you @OsBlaineOra for the improvement.
Four of our tests require updates in order for the build to be successful.
Are you able to fix those?
You can check the results of the failing tests here:
https://app.travis-ci.com/github/utPLSQL/utPLSQL/jobs/536073612#L6829

@@ -90,9 +91,11 @@ create or replace type body ut_coverage_cobertura_reporter is
--write header
ut_utils.append_to_list(
l_result,
'<coverage line-rate="0" branch-rate="0.0" lines-covered="'
'<coverage line-rate="'
||to_char(round((case l_lines_valid when 0 then 0 else a_coverage_data.covered_lines/(l_lines_valid) end), 17), rpad('FM0.',21,'9'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should probably be:
to_char( value , 'TM9' , 'NLS_NUMERIC_CHARACTERS=''. ''' ) to make sure it is OK for values of "0".

See those failing tests for extra "." present there.
The tests need to be fixed as they all assume the line-rate to be ZERO.
https://app.travis-ci.com/github/utPLSQL/utPLSQL/jobs/536073612#L6935

@jgebal jgebal merged commit b4c7db8 into utPLSQL:develop Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants