title: How to run gtest?
body: <p>I'm new to using gtest (actually, C++ in general)
  I'm making an application where I need to have unit tests (using CLion IDE, in case if that matters).</p>
  
  <p>The steps I followed:</p>
  
  <ol>
  <li>Download gtest from <a href="https://github.com/google/googletest" rel="nofollow noreferrer">GitHub</a>.</li>
  <li>Extracted the zip file into a new <code>lib</code> directory in my project.</li>
  <li><p>Modify CMakeLists.txt</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.13)
  project(my_project)
  
  set(CMAKE_CXX_STANDARD 14)
  
  add_subdirectory(lib/gtest) # I renamed googletest-master folder to gtest, so that should be fine.
  include_directories(lib/gtest/googletest/include)
  include_directories(lib/gtest/googlemock/include)
  
  add_executable(my_project main.cpp blablabla1.h blablabla1.cpp blabla2.h blabla2.cpp etc...)
  
  target_link_libraries(my_project gtest gtest_main)
  </code></pre></li>
  <li><p>Created a new directory called <code>Tests</code> and added a cpp file in it with the following code:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include "gtest/gtest.h"
  #include "gmock/gmock.h"
  
  TEST(TrivialTest, Negative) {
      ASSERT_EQ(0, 1);
  }
  </code></pre></li>
  <li><p>I'm stuck here, how should I run this test? If I put the following code in <code>main</code> function, then tests will start every time a normal run to the program is made. I want to somehow separate the normal program running, from the unit tests running.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include "gtest/gtest.h"
  #include "gmock/gmock.h"
  
  int main() {
      testing::InitGoogleTest();
      return RUN_ALL_TESTS();
  }
  </code></pre></li>
  </ol>