Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Problems with cmake, gtest and auto test plugin
QtWS25 Last Chance

Problems with cmake, gtest and auto test plugin

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
4 Posts 4 Posters 2.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V. B. MacitV Offline
    V. B. MacitV Offline
    V. B. Macit
    wrote on last edited by
    #1

    I have tried several things but I always get 0 passes 0 failed even I select debug&run test with or without deployment there is no effect. is this a bug or what should I do?0_1490603071551_Screenshot_2017-03-27_11-20-06.png

    A 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You need to give more details about your project, what exactly fails, what version of Qt you are using, platform etc.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • V. B. MacitV V. B. Macit

        I have tried several things but I always get 0 passes 0 failed even I select debug&run test with or without deployment there is no effect. is this a bug or what should I do?0_1490603071551_Screenshot_2017-03-27_11-20-06.png

        A Offline
        A Offline
        ambershark
        wrote on last edited by
        #3

        @V.-B.-Macit I have used make test with cmake and testing using google test. I have not used the auto test plugin, but the rest should work.

        Maybe share your CMakeLists.txt and exactly what you are doing and what results you expect versus what results you get.

        My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

        1 Reply Last reply
        1
        • B Offline
          B Offline
          bonthink
          wrote on last edited by
          #4

          The project is created with autotest. The code is the default one.

          // tst_test_example.h

          #include <gtest/gtest.h>
          #include <gmock/gmock-matchers.h>
          
          using namespace testing;
          
          TEST(test_example, FirstTest)
          {
              EXPECT_EQ(1, 1);
              ASSERT_THAT(0, Eq(0));
          }
          
          

          // main.cpp

          #include "tst_test_example.h"
          #include <gtest/gtest.h>
          
          int main(int argc, char *argv[])
          {
              ::testing::InitGoogleTest(&argc, argv);
              return RUN_ALL_TESTS();
          }
          

          CMakeLists.txt

          CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
          
          PROJECT(test_example
                  LANGUAGES CXX)
          
          find_package(Threads REQUIRED)
          
          if ($ENV{GOOGLETEST_DIR})
              SET(GOOGLETEST_DIR $ENV{GOOGLETEST_DIR})
          else ()
              message(WARNING "Using googletest src dir specified at Qt Creator wizard")
              SET(GOOGLETEST_DIR "/home/aburov/Projects/3rd/googletest")
          endif ()
          if (EXISTS ${GOOGLETEST_DIR})
              SET(GTestSrc ${GOOGLETEST_DIR}/googletest)
              SET(GMockSrc ${GOOGLETEST_DIR}/googlemock)
          else ()
              message( FATAL_ERROR "No googletest src dir found - set GOOGLETEST_DIR to enable!")
          endif ()
          
          include_directories(${GTestSrc} ${GTestSrc}/include ${GMockSrc} ${GMockSrc}/include)
          
          add_executable(${PROJECT_NAME} main.cpp tst_test_example.h
                         ${GTestSrc}/src/gtest-all.cc
                         ${GMockSrc}/src/gmock-all.cc)
          add_test(${PROJECT_NAME} COMMAND ${PROJECT_NAME})
          target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads)
          

          Here is the result of running (successful)
          alt text
          image

          But when run via Tools->Tests->Run All Tests
          alt text
          image

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved