nifengfei
15 years agoOccasional Contributor
Code coverage seems not correct
hi experts,
I use AQtime to do the code coverage for my applications using my tests, I do not that trust about the result. then i write a simple code to test it. It seems that the code coverage profile is wrong whatever by line or by routine level.
the following is my steps:
1. using vs2008 to create a Win32 Console Application using c++;
2. put the following codes:
***codes start***
#include "stdafx.h"
class Hello
{
private:
int x;
int y;
public:
Hello()
{
x=10;
y=10;
}
int Add()
{
return x+y;
}
int Sub()
{
return x-y;
}
~Hello()
{
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Hello *aHello= new Hello();
return aHello->Sub();
}
***codes end***
3. build the above project in debug mode
4. create an AQtime project, select coverage profile, add the above exe as the module to be profiled, check "Full Check by Lines" & "by Lines", and click run.
5. after finishing the profile, result is: by line 90.91%, by routine 100%!!!
obviously, in my code, i didnot call the function Add, but why the result is 100%.
further, i add another constructor for this class as following:
Hello(int x, int y)
{
this->x=x;
this->y=y;
}
build->using AQtime to profile, the result is the same as the previous. by line is 90.91%!!! why I added another meaningful codes, but the same calls, the by line result doesnot change?
so my question is:
1. Is the result generated by AQtime correct?
2. If it is, how does AQtime to count the base line number, base routine number and the hit lines, routines?
Looking forward to your reply. thanks.
I use AQtime to do the code coverage for my applications using my tests, I do not that trust about the result. then i write a simple code to test it. It seems that the code coverage profile is wrong whatever by line or by routine level.
the following is my steps:
1. using vs2008 to create a Win32 Console Application using c++;
2. put the following codes:
***codes start***
#include "stdafx.h"
class Hello
{
private:
int x;
int y;
public:
Hello()
{
x=10;
y=10;
}
int Add()
{
return x+y;
}
int Sub()
{
return x-y;
}
~Hello()
{
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Hello *aHello= new Hello();
return aHello->Sub();
}
***codes end***
3. build the above project in debug mode
4. create an AQtime project, select coverage profile, add the above exe as the module to be profiled, check "Full Check by Lines" & "by Lines", and click run.
5. after finishing the profile, result is: by line 90.91%, by routine 100%!!!
obviously, in my code, i didnot call the function Add, but why the result is 100%.
further, i add another constructor for this class as following:
Hello(int x, int y)
{
this->x=x;
this->y=y;
}
build->using AQtime to profile, the result is the same as the previous. by line is 90.91%!!! why I added another meaningful codes, but the same calls, the by line result doesnot change?
so my question is:
1. Is the result generated by AQtime correct?
2. If it is, how does AQtime to count the base line number, base routine number and the hit lines, routines?
Looking forward to your reply. thanks.