Toad World® Forums

Code Coverage : More than 100%


#1

Hi,

I am currently testing the coda coverage and I would have more informations about this.

  1. How do you do to calculate the score?

  2. The score depend unit test or package?

Example :

I tested this :

CREATE OR REPLACE PACKAGE test AS
FUNCTION getName(v_id IN NUMBER) RETURN VARCHAR2;
END test;

CREATE OR REPLACE PACKAGE BODY test AS
FUNCTION getName(v_id IN NUMBER) RETURN VARCHAR2 IS
v_name VARCHAR2(30);
BEGIN
select name into v_name from emp where id = v_id;
RETURN v_name;
END;
END ;

I test only that there are no exception and I have a score (30%).

If I change my function :

FUNCTION getName(v_id IN NUMBER) RETURN VARCHAR2 IS
v_name VARCHAR2(30);
BEGIN
– I add anything
if 1=2 then
select name into v_name from emp where id = v_id;
RETURN v_name;
if 1=2 then
select name into v_name from emp where id = v_id;
RETURN v_name;
end if;
end if;
select name into v_name from emp where id = v_id;
RETURN v_name;
END;

–> I have a score of 80% ??? Why?

Thank you for your help…

EDIT : If i extend the code with 1=2, I get a score of over 100%

Message was edited by: Dago


#2

Those are very strange numbers. I will need to take a look at our algorithm and determine what is causing this.

The score should only include the code within that program unit.

SF


#3

I ran test and Code Coverage report on your first simplest implementation and saw this:

GETNAME (Function) (FAILURE)
Total execution time : 40000000
Run completed on : 2010-04-08 09:12:51
Code Coverage Analysis (%):
Actual coverage when test was run : 100
Target coverage when test was run : 80
Target currently set for program : 80

then I compiled the longer version, ran test and got this:

GETNAME (Function) (RUNTIME-ERROR)
Total execution time : 33000000
Run completed on : 2010-04-08 09:16:04
Code Coverage Analysis (%):
Actual coverage when test was run : 120
Target coverage when test was run : 80
Target currently set for program : 80

000003 0000008345 0000000002 FUNCTION getname (v_id IN NUMBER)
000008 0001997322 0000000001 SELECT last_name
000009 0000000000 0000000001 IF 1 = 2
000013 0000001908 0000000001 RETURN v_name;
000014 0000001062 0000000001 END;
000029 0003523378 0000000001 SELECT ename

Well, something is definitely wrong! It looks like it is using some of the lines from the previous execution (that reference to last_name, for example).

Also this is different from what you report. Can you please go through the steps and take screen shots or save reports to files and send them to me: steven.feuerstein@quest.com.

Regards, Steven