Alex Rivera | Logout

Unit testing of private methods in C++

Asked 2010-09-09T12:51:20.767
138

I am in the process of writing some unit tests. In particular I want to test some private methods.

So far the I have come up with using.

#define private public

But I am not happy with this as it will destroy all encapsulation from the point of view of the unit test.

What methods do you use to unit-test private methods.

Edit
Report

1 Answer

-3

I don't think unit test cases would be required for private methods.

If a method is private it can used only within that class. If you have tested all the public methods using this private method then there is no need to test this separately since it was used only in those many ways.

answered 2010-09-09T13:00:39.733

Your Answer