Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-20280

gTest: Silent test failures if the test environment setup hits an exception

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • Qt Creator 4.6.1
    • Qt Creator 4.6.0
    • Test Integration
    • None
    • 54f024dba419b7680453c16bdfc1b84706d0209c

    Description

      If the test environment setup fails Qt Creator completely ignores/skips the affected tests (so real failures can be easily missed because of this). A small example:

      #include <gtest.h>
      #include <exception>
      
      class TestEnvironment : public testing::Environment {
      {{ void SetUp() override { throw std::exception(); }}}
      };
      
      TEST(Foo, Dummy) {
      }
      
      int main(int argc, char *argv[]) {
       testing::InitGoogleTest(&argc, argv);
       testing::AddGlobalTestEnvironment(new TestEnvironment);
       return RUN_ALL_TESTS();
      }

      Regarding the reliance on parsing the output from gtest, this paragraph from the google test documentation is very relevant:

      "Important: You must not ignore the return value of RUN_ALL_TESTS(), or gcc will give you a compiler error. The rationale for this design is that the automated testing service determines whether a test has passed based on its exit code, not on its stdout/stderr output; thus your main() function must return the value of RUN_ALL_TESTS()."

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            cstenger Christian Stenger
            lemo L M
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes