Hi guys,
I am trying to create a bunch of unit test cases for my program to get some good code coverage number. Let's suppose that the following is the code that I want to test against.
Code:
class A
{
public:
...
HRESULT func()
...
}
HRESULT A::func()
{
HRESULT hr = S_OK;
...
hr = SomeFunction(...);
if(FAILED(hr))
{
Log(L"some log message")
...Do some cleanups before exiting the function...
goto Exit;
}
...
Exit:
return hr;
}
For those of you who have experience with unit testing, when you test the class A, would you intentionally make the "SomeFunction(...)" fail (if possible) so that your unit test case would cover(test) even the error-handling codes inside of the if(FAILED(hr)) block? I am trying to figure out where should I draw the line between the things I need to test and things that I don't need to test. Thanks!