[Interest] How do I mock QHostInfo::lookupHost?

Thiago Macieira thiago.macieira at intel.com
Sun May 3 04:01:11 CEST 2020


On Saturday, 2 May 2020 12:14:47 PDT Doogster wrote:
> How do I mock QHostInfo::lookupHost() for unit testing?
> 
> When I looked for a solution, all I found was someone who just gave up and
> said:
> 
> "Unfortunately QHostInfo::lookupHost is a static method, so we can’t
> mock it."

For Qt's unit-test, we created a real DNS zone used for testing. We know what 
the results will be.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products





More information about the Interest mailing list