Using CMake's CTest to create and run all your C++ tests

Поделиться
HTML-код
  • Опубликовано: 28 авг 2024

Комментарии • 16

  • @codingwithmat
    @codingwithmat  Год назад +6

    Let me know if you guys have any issues with creating tests with CMake!

  • @theBurningTreeComedy
    @theBurningTreeComedy Год назад +1

    Excellent tutorial, I am new to using Cmake and this helped both with writing CMakeLists and unit tests.
    Greetings from Wisconsin, USA!

    • @codingwithmat
      @codingwithmat  Год назад

      Thank you for watching! Glad the video has helped you. Love to my American brothers!

  • @intjengineering
    @intjengineering Год назад +4

    That's top-quality stuff, Man. Thank you so much!
    And your blog? 👌🏽❣️❣️❣️
    Congratulations, Man. It's extremely well done.
    Greetings from Germany.

    • @codingwithmat
      @codingwithmat  Год назад +4

      Thanks my friend, glad to know the German engineers are liking the blog!

    • @juanherrera3919
      @juanherrera3919 Год назад

      ​@@codingwithmat Thank you for the video.
      Ctest is equal to Gtest?, why the multiply_tests script has include Gtest?. Thank you in advance.

    • @codingwithmat
      @codingwithmat  Год назад

      @@juanherrera3919 Thanks for watching, Juan.
      Basically, GTest is a C++ library that allows you to create test executables easily. I.e. it's a C++ testing framework. GTest won't do anything else aside from letting you create test programs.
      CMake's CTest is a test management framework. This means that it manages all the test executables you created with C++. For example, it will "collect" all of your tests and run all of them, run some of the tests you want, run the test executables in random orders, etc. CTests should manage the running of your GTest executables, that's why they go hand in hand.
      The "multiply_test" CMake includes (really the work here is "link") because it uses the GTest library to create the tests in the C++ code.
      If you need more help, please subscribe and join the discord! I can give you live help in there.
      Thanks,
      Matheus Gomes.

  • @jairomejia616
    @jairomejia616 6 месяцев назад

    Hi, Thanks for basic explanation of how this works! I have found that in my case, the header with is not working. The linker does not found the file and I have the exact CMakeLists.txt file as you. I used the local "" includes and works. Did you have any idea why?
    Thanks!

    • @jairomejia616
      @jairomejia616 6 месяцев назад

      Ohh forget it, I found it, you have an extra folder inside of multiply where you save the header. Thanks for your videos!

    • @codingwithmat
      @codingwithmat  6 месяцев назад

      I was gonna say, sometimes when you use a header from a more recent standard than what you have set, then this behaviour can also happen!

  • @r2com641
    @r2com641 Год назад

    Maybe make some video on why cmake and not meson, like what are advantages of using that

    • @codingwithmat
      @codingwithmat  Год назад

      I need to do some research on meson! I personally never used meson (other than when integrated with package managers) as most projects seem to use CMake out of popularity! But I agree, it's definitely a good video idea :)

  • @chrislam1341
    @chrislam1341 5 месяцев назад

    if i am not using Gtest, is it 1 test per .cpp?
    lets say I have > 1 tests in a test_multi.cpp, while the main function can only return 1 and 0
    i.e.
    ```
    bool test1() { return false; };
    bool test2() { return true; };
    int main() {
    bool r1 = test1();
    bool r2 = test2();
    r1 && r2? return 0 : return 1;
    }
    ```
    how can i know which tests passed which failed by running `ctest`

    • @codingwithmat
      @codingwithmat  5 месяцев назад

      I think we answered this on the discord right?

    • @chrislam1341
      @chrislam1341 5 месяцев назад

      @@codingwithmat yes, thanks alot!

  • @BasilKepler
    @BasilKepler День назад

    Have you still been using that shitty soft? Really?