-
Notifications
You must be signed in to change notification settings - Fork 185
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
Replaced hard coded 0 in total test coverage #1140
Conversation
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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="' |
There was a problem hiding this comment.
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!
Thank you @OsBlaineOra for the improvement. |
@@ -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')) |
There was a problem hiding this comment.
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
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.