Automated test question

Michael Stemle themanchicken at gmail.com
Sun Feb 16 02:25:21 UTC 2014


So, I'm still getting used to the dpointer paradigm. Is anybody familiar
with how to use QTest to simulate code paths dependent on values in the
dpointer which have no exposed mutators?

For instance, I have QApt::Transaction which has its dpointer, and its
dpointer has a property "error". This property is exposed via a Q_PROPERTY
macro in the public class, but it's read-only. I'm adding error handling
and I'd like to add some unit tests for the error handling, but I'm having
trouble figuring out how to force an instance of QApt::Transaction into
executing that error handling without violating encapsulation or adding a
klugy method just for my test.

I see that Google Mock has something that looks like it could be useful (
https://code.google.com/p/googlemock/wiki/CookBook#Mocking_Private_or_Protected_Methods),
but that sounds like a new dependency that I don't think we want to add to
the library.

Any suggestions are welcome, including ones that may or may not point out a
gaping hole in my knowledge of Qt or C++, which I concede ahead of time.

Much thanks.

-- 
~ Michael D. Stemle, Jr.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/kubuntu-devel/attachments/20140215/fa7c137c/attachment.html>


More information about the kubuntu-devel mailing list