18.05.2017, 13:35, "Shantanu Tushar" <[email protected]>: > Hi, > > In one of the unit tests that I am trying to write, I call a function > that makes a get() call using a QNetworkAccessManager that I pass to > it. It looks something like this- > > bool trackEvent(QString event, QNetworkAccessManager *nam); > > However, I do not want actual HTTP calls being made during the unit > test, so I thought I'll write a FakeNetworkAccessManager and pass that > (where I write a mock get()). The issue is that the get() on > QNetworkAccessManager is not virtual, so at the end my mock get() is > useless.
You need to override createRequest() You may also need to add mock subclass for QNetworkReply. > > Any recommendations on how to do I achieve the unit test without > needing network access? > > Cheers, > > -- > Shantanu Tushar (UTC +0530) > shantanu.io > _______________________________________________ > Interest mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/interest -- Regards, Konstantin _______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
