Discussion:
[Cppunit-devel] How to Test a Module that is dependent on other module?
CppUnit development mailing list
2007-06-04 05:32:36 UTC
Permalink
Hi All.
Can Any body tell me how to test any module that is itself dependent on
other modules.
For example.
i have class A having module named aProc().
And suppose aProc() makes a call to any module declared in other class, lets
say B.
as
class A
{
//...
bool aProc()
{
B b;
if ( b.bProc()) // Call to B class' function
{
// DO SOMETHING
}
else
{
//DO SOMETHING
}

}

So here in Class A aProc() is dependent on b.bProc()'s output.
So my question is that do i need to make a TestSuits for class B also along
with class A.
Remember i want to unit test only Class A and not B.

Regards,
Sandeep.
CppUnit development mailing list
2007-06-04 09:07:59 UTC
Permalink
Hello Sandeep,
Post by CppUnit development mailing list
Can Any body tell me how to test any module that is itself dependent on
other modules.
For example.
i have class A having module named aProc().
And suppose aProc() makes a call to any module declared in other class,
lets say B.
[...]
Post by CppUnit development mailing list
So here in Class A aProc() is dependent on b.bProc()'s output.
So my question is that do i need to make a TestSuits for class B also along
with class A.
Remember i want to unit test only Class A and not B.
What is the reason that you do not want to test class B in your scenario?
Usually, you should do so also.

But I assume that you are not able to test B for some reason (e.g. due to
remote implementation or something else). In this case it is common sense to
use a stub or a mock object of class B.

In C++ you can simply exchange the B.cpp implementation file, for example, and
provide your own implementation. This could be rather empty and just enough
code that A is working (stub), or it could contain additional test code that
tests for, e.g., known input/output values or a counter of the amount of
calls to B::bProc(). The latter would be a mock object.

I hope I got the point and this was help for you. :-)

Kind regards,
Marcel
--
Marcel Winandy
http://www.prosec.rub.de/staff/winandy.html
Horst Görtz Institute for IT Security, Ruhr-University Bochum
CppUnit development mailing list
2007-06-06 09:42:37 UTC
Permalink
Hello
Ya i got what you wanna say.
But i have another problem....
Suppose i want to create test cases for system calls. for e.g. a call to
createthread()
or to createevent. how to provide test cases for those calls
Suppose i replace those system calls with dummy functions. that's fine but i
think it will clash with system dlls. then how do i tackle this problem.

Thanks.




On 6/4/07, CppUnit development mailing list <
Post by CppUnit development mailing list
Hello Sandeep,
Post by CppUnit development mailing list
Can Any body tell me how to test any module that is itself dependent on
other modules.
For example.
i have class A having module named aProc().
And suppose aProc() makes a call to any module declared in other class,
lets say B.
[...]
Post by CppUnit development mailing list
So here in Class A aProc() is dependent on b.bProc()'s output.
So my question is that do i need to make a TestSuits for class B also
along
Post by CppUnit development mailing list
with class A.
Remember i want to unit test only Class A and not B.
What is the reason that you do not want to test class B in your scenario?
Usually, you should do so also.
But I assume that you are not able to test B for some reason (e.g. due to
remote implementation or something else). In this case it is common sense to
use a stub or a mock object of class B.
In C++ you can simply exchange the B.cpp implementation file, for example, and
provide your own implementation. This could be rather empty and just enough
code that A is working (stub), or it could contain additional test code that
tests for, e.g., known input/output values or a counter of the amount of
calls to B::bProc(). The latter would be a mock object.
I hope I got the point and this was help for you. :-)
Kind regards,
Marcel
--
Marcel Winandy
http://www.prosec.rub.de/staff/winandy.html
Horst Görtz Institute for IT Security, Ruhr-University Bochum
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Cppunit-devel mailing list
https://lists.sourceforge.net/lists/listinfo/cppunit-devel
Loading...