[Interest] Fwd: Is there a way to mock the QNAM?
Philipp Kursawe
phil.kursawe at gmail.com
Tue Sep 3 09:58:52 CEST 2013
I did not find a way to write unit-tests for my QNAM based code. My
objects take a QNAM and perform operations with it like ::get() and
::post()
Of course for Unit tests it should not really perform network
requests. The usual way to test such things is to mock the network
layer. However, since none of the get/post/put methods in QNAM are
virtual I cannot override them :( My only solution for now is to use
an interface based approach and not hand in the QNAM but rather an
interface that looks like this:
struct HttpClient {
virtual QNetworkReply* get(const QNetworkRequest&) const;
...
}
This is then easily mockable.
Any other ideas?
More information about the Interest
mailing list