Home / C/C++ / Verify your code with Google test

Verify your code with Google test

  • What is GTEST?

Google Test (also known as gtest for e.g. the ROS environment) is a unit testing library for the C++ programming language, based on the xUnit architecture. The library is released under the BSD 3-clause license. It can be compiled for a variety of POSIX and Windows platforms, allowing unit-testing of C sources as well as C++ with minimal source modification. The tests themselves could be run one at a time, or even be called to run all at once. This makes the debugging process very specific and caters to the need of many programmers and coders alike.

  • Types of GTest

» Unit Tests

» Integration Tests

» Acceptance Tests

Gtest1

  • How to use GTest? 

We build a template environment using GTest

(We attached the project on bellow of post)

After download, follow the steps below.

Step 1: Copy your source code to sample folder

Step 2: Open VS solution FreeSourceC_DevEnv.sln

Step 3: Add the code (from sample folder ) to Models in FreeSource_Bench

(ex: Square.cpp and Square.h)

Step 4: add include Directory for your source code

   FreeSource_Bench property -> VC++ Directories -> Include Directories

Step 5: Modify UnitTest.cpp

   use macro TEST(test_case_name, test_name) to make your test case.

Note: Square model is an example model. You can delete it if you want.

Download Project (VS2015):

Google Drive 1

__FreeSourceC.com__

About admin

Check Also

How does GCOV work?

GCOV sử dụng hai tệp để phân tích. Tên của các tệp này được bắt …

Leave a Reply

Your email address will not be published. Required fields are marked *