Using Google Test with QtCreator and AutoTest plugin



  • Unit tests don't seem to run, although recognized by QtCreator.

    Here's the full story:

    I followed the manual describing how to use Google Test framework in QtCreator with AutoTest plugin, and wrote several simple unit tests for my project (the project itself is roughly equivalent to the default "Qt Widget Application"). Currently:

    • there's a Google Test 1.7 release sources residing in the project's root directory
    • project.pro contains these lines
    INCLUDEPATH += gtest/include gtest
    SOURCES += gtest/src/gtest-all.cc tests/project_unittest.cc
    
    • tests/project_unittest.cc contains
    #include "gtest/gtest.h"
    #include "Point.h"
    
    TEST(PointOps, ScalarMagnification) {
      Point p = {-4, 3, 1};
      double r = 3.5;
      Point result = {-14, 10.5, 3.5};
      EXPECT_EQ(p * r, result);
      EXPECT_EQ(r * p, result);
    }
    
    TEST(PointOps, UnitaryMinus) {
      Point p = {-4, 3, 0};
      Point result = {4, -3, 0};
      EXPECT_EQ(-p, result);
    }
    

    I can see the tests in the "Tests" pane, but when I run them the project's main() gets executed instead and the "Test Results" pane shows "Test summary: 0 passes, 0 fails".



  • @Dmitry-Zotikov you may want to take a look at this web training session



  • @Pablo-J.-Rogina thanks! I'll take a look.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.