C ++ code testing: using test libraries

I have been studying C ++ for a while, but this is the first time I am participating in a C ++ (pet analyzer library) project. To test this, I use the Google C ++ Testing Framework . But I do not know if I am doing this correctly.

I have currently ripped some parts of this Google test library and put it in my Test/googletest . It works fine, but I wonder how I should do it. I have included the source code of the testing framework in my project and it will be released with my code. It makes me feel uncomfortable.

I wandered through some C ++ projects on GitHub , trying to understand how other people handle this. Some have custom frameworks, and most of them solve the whole problem without testing the code at all.

I wonder if I accept it correctly, or in some other way, how can I apply a testing method that will contain a structure from my source tree and allow me to release my code using tests that can be embedded and executed by the user?

+4
source share
1 answer

As for your build, you are doing everything right. The gtest readme states that building a gtest (you can package libgtest.a from two object files) along with your project is the preferred way to do this.

Regarding distribution: Ideally, you can use the build tool (make, CMake, etc.) to check / extract the required version of gtest from your own repository. But I don’t think there is much harm if you add an “external” folder to your project and include things like gtest in your own repository.

+3
source

Source: https://habr.com/ru/post/1485576/


All Articles