cpp-unit-testing

Write and review C++ unit tests for embedded automotive software using Google Test and Google Mock.

1|Updated Feb 28, 2026
One-click install
npx skills add https://github.com/Binh230199/ai --skill cpp-unit-testing-binh230199
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-unit-testing
Source: https://github.com/Binh230199/ai/tree/main/.github/skills/cpp-unit-testing
Command: npx skills add https://github.com/Binh230199/ai --skill cpp-unit-testing-binh230199

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps teams create, review, and debug deterministic C++ unit tests for embedded automotive software, especially when production code depends on hardware, operating system services, or other hard-to-isolate interfaces.

Core Features & Use Cases

  • Test structure: Uses Arrange-Act-Assert, fixture setup, and clear naming to keep tests readable and maintainable.
  • Mocking and isolation: Builds gmock-based test doubles for HAL and OS dependencies with StrictMock, NiceMock, and expectation-driven verification.
  • Coverage and CI readiness: Guides CMake integration, test discovery, parameterized tests, death tests, and coverage workflows for gtest-based projects.
  • Typical use cases: Writing new tests for a module, reviewing brittle tests, characterizing legacy behavior before refactoring, and validating coverage targets.

Quick Start

Ask for a unit test plan or implementation for a specific C++ class or module, and have it follow AAA structure, gtest/gmock conventions, and embedded CMake integration.

Frequently Asked Questions about cpp-unit-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write deterministic C++ unit tests for embedded automotive software?

C++ unit tests for embedded automotive software require isolating hardware and OS dependencies using Google Test and Google Mock. Structure tests with Arrange-Act-Assert and define test doubles for hard-to-isolate interfaces to ensure reproducible verification.

What is the best way to mock HAL and OS dependencies using gmock?

Mocking HAL and OS dependencies using gmock involves building test doubles with StrictMock or NiceMock. This approach applies expectation-driven verification to isolate production code from hardware and operating system services during C++ unit testing.

How do I integrate gtest with CMake for parameterized tests and code coverage?

Integrating gtest with CMake for parameterized tests and code coverage requires configuring CMake test discovery and coverage workflows. This setup supports parameterized tests, death tests, and validates coverage targets for gtest-based projects.

Does this gtest workflow support embedded targets like QNX and Android NDK?

This gtest workflow supports embedded targets including QNX and Android NDK. It applies to Google Test and Google Mock workflows for IVI, HUD, RSE, and Linux environments, ensuring tests remain fast and maintainable across platforms.

Why should I use the Arrange-Act-Assert structure for C++ unit testing?

Using the Arrange-Act-Assert structure for C++ unit testing keeps tests readable and maintainable. This structure separates setup, execution, and verification, ensuring deterministic isolation and clear naming for gtest-based projects.

Can I use gmock to characterize legacy C++ behavior before refactoring?

You can use gmock to characterize legacy C++ behavior before refactoring by building test doubles for dependencies and applying expectation-driven verification. This approach captures existing functionality and validates coverage targets safely.