I am trying to understand SQL Developer Unit Testing feature set. As code coverage is a feature provided in this tool, I am trying to understand the coverage statistics produced as a result of the same.
Given a procedure like this:
1 PROCEDURE award_bonus(emp_id NUMBER, sales_amt NUMBER) AS
2 commission REAL;
3 comm_missing EXCEPTION;
5 SELECT commission_pct into commission
6 FROM employees
7 WHERE employee_id = emp_id;
9 IF commission IS NULL THEN
10 RAISE comm_missing;
12 UPDATE employees
13 SET salary = salary + sales_amt * commission
14 WHERE employee_id= emp_id;
15 END IF;
16 END award_bonus;
I see a few issues in the way Total_Lines and Total_Occurences are being calculated:
for instance, in the above example
==> lines 2 and 3 above are not added to "Total_Occurences" but are added to "Total_Lines"
My understanding: Either they should not be added to "Total_Lines" or should be added to "Total_Occurences" to be correct.
==> lines 12 to 14 are counted as 3 and added to "Total_Lines". "Total_Occurences" is calculated as 1 which is right.
My understanding: Irrespecitve of the number of lines, each STATEMENT should be treated as 1. Hence, lines 12 to 14 should be counted as 1.
Please suggest if my understanding is correct. If yes, is there way to fix these issues.
Thanks & Regards,
These are providing wrong results with respect to the coverage.
SQL Developer collects the statistics for code coverage using the DBMS_PROFILER database package, which is described here,
Does this help to answer your questions?
Thanks for the link. I understand that the code coverage is gathered by the DBMS_Profiler. However, my point is that it is not calculating the code coverage accurately (as explained in my initial post) which causes resistence among teams to adopt this otherwise very good unit testing featureset.
Thanks & Regards,
Thank you for pointing out this issue. I've raised a bug, #16217315, to find out whether some additional functionality can be added
to help improve our code coverage support in the way you suggest.