Search code examples
qtqtestlib

How to verify with QTest that an exception is thrown?


I'm stating in QT C++ world. I'm doing TDD using QTest class. I want to verify that in certain conditions an exception is thrown by my class under test. Using google test, I would use something like:

EXPECT_THROW(A(NULL), nullPointerException);

Does it exists something like this feature in QTest? O at least a way to do it?

Thanks!


Solution

  • Since Qt5.3 QTest provides a macro QVERIFY_EXCEPTION_THROWN that provides the missing feature.