Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW-A-41] Add google test setup #25

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

sDutkiewicz
Copy link

@sDutkiewicz sDutkiewicz commented Aug 14, 2022

Resolves: FW-A-41

@sDutkiewicz sDutkiewicz added New feature New feature or request CI/CD Issues related to the CI/CD configuration Testing Task related to testing labels Aug 14, 2022
@sDutkiewicz sDutkiewicz self-assigned this Aug 14, 2022
@John15321 John15321 changed the title [FW-A-41] Add google test setup Draft: [FW-A-41] Add google test setup Aug 15, 2022
@John15321 John15321 force-pushed the 21-fw-a-41-add-basic-google-test-setup branch from 9b0483e to d82f28e Compare August 20, 2022 16:13
@sDutkiewicz
Copy link
Author

Let's start with the explanation what it is.

Google Test is a unit test library for C++ programming language, based on xUnit architecture. It can be compiled for a variety of platforms (Windows, MacOS, Linux), allowing unit testing of both C and C++ sources with minimal source modification. It is mostly used to test the part of code if it is compiling efficiently.

When you use googletest, you start by writing which are statements that check if a condition is true. Tests use assertions to verify the code behaviour under test. If a test crashes or has an assertion that then it fails otherwise it succeeds. The result of an assertion can be success, nonfatal, or fatal failure. If a fatal failure occurs, it aborts the current one, otherwise the program continues normally.

A validation suite contains one or many tests. Tests can be grouped your tests into suites that reflect the structure of the code being tested. When multiple tests in a test suite need to share common objects and subroutines, you can place them in a test fixture class.

Besides being developed and used at Google, many other projects implement Google Test as well:
• Android Open Source Project operating system
• Chromium projects (behind the Chrome browser and Chrome OS)
• LLVM compiler
• Protocol Buffers (Google's data interchange format)
• OpenCV computer vision library
• Gromacs molecular dynamics simulation package

On the next post, I will describe functions with more details and display an example.

@John15321 John15321 force-pushed the 21-fw-a-41-add-basic-google-test-setup branch from d82f28e to 96ac266 Compare August 22, 2022 22:39
@John15321 John15321 changed the title Draft: [FW-A-41] Add google test setup Draft: [FW-A-41] Add google test setup Aug 22, 2022
@sDutkiewicz
Copy link
Author

The whole test (directory) gets built only if unit tests are not disabled globally during configuration.

The only thing you must do in your test source file is to include 'gtest/gtest.h' and insert a default main routine that triggers the tests you write before.

TEST and TEST_F implicitly register their tests with googletest. So, unlike many other test frameworks, you don't need to list all your tests to run them. After defining your tests, you can run them RUN_ALL_TESTS, which returns 0 if all tests are, or 1 otherwise.

RUN_ALL_TESTS runs all binding tests. They can come from different suites or even from different source files.

@John15321 John15321 force-pushed the 21-fw-a-41-add-basic-google-test-setup branch from 3eb6488 to e657432 Compare August 26, 2022 18:13
@John15321 John15321 force-pushed the 21-fw-a-41-add-basic-google-test-setup branch from e657432 to 0e2b737 Compare August 30, 2022 10:18
@John15321 John15321 marked this pull request as draft August 31, 2022 21:03
@John15321 John15321 changed the title Draft: [FW-A-41] Add google test setup [FW-A-41] Add google test setup Aug 31, 2022
@John15321 John15321 added this to the 🧪 Unit test milestone Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/CD Issues related to the CI/CD configuration New feature New feature or request Testing Task related to testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FW-A-41] Research and create a basic Google Test setup for the project
2 participants