Only require QtTest if needed

Fixes upstream part of https://bugs.gentoo.org/show_bug.cgi?id=507086