Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTest pass empty parameter



  • I am performing tests in one unit

    Unit:

    @QSqlDatabase* conection(QSqlDatabase cnx, QObject evoker = 0) /.h file/@

    Test:

    @void TestDataAccess::testConection_data()
    {
    QTest::addColumn<QObject*>("parente");
    QTest::addColumn<bool>("banco");

    QTest::newRow("Normal") << qobject_cast<QObject *>(this) << true;
    }

    void TestDataAccess::testConection()
    {
    QSqlDatabase objdata;

    QFETCH(QObject*, parente);
    QFETCH(bool, banco);
    QCOMPARE(DataAccess::instance()->conection(&objdata, parente)->open(), banco);

    if(objdata.isOpen()) /If conections is open, close conection/
    objdata.close();

    objdata.removeDatabase(objdata.connectionName()); /Remove conection/
    }@

    In "Normal" test line, I'm calling the method with all parameters. How do I do a line test that does not pass the QObject parameter, using the default value, in this case, 0?


Log in to reply