当前位置:网站首页>GTEST from ignorance to proficiency (4) how to write unit tests with GTEST

GTEST from ignorance to proficiency (4) how to write unit tests with GTEST

2022-07-04 21:41:00 Wonderful binary

1 gtest What is it?

gtest yes Google Developed a cross platform open source unit testing framework ,git Warehouse click here to get . Mainly aimed at c/c++,gtest It has the following characteristics :

  • The test framework

  • Automatically collect test cases , No need for developers to organize again

  • Provides a powerful set of assertions , Support includes Boolean 、 integer 、 floating-point 、 String, etc.

  • Provides custom extensions for assertion methods

  • Provide death test function

  • Common use case initialization and cleaning can be put into the test fixture , from gtest Automatically call

  • Value-parameterized tests.

  • Type-parameterized tests.

  • Generate xml Format test report

2. Define a basic test case

TEST Macros are used to define a test case :

#include <gtest/gtest.h> 

int Add(int i
原网站

版权声明
本文为[Wonderful binary]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207042048259712.html