Agent skill
embedded-testing
Embedded systems testing patterns, hardware-in-the-loop
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/embedded-testing
SKILL.md
Skill: embedded-testing
What I do
I provide expertise in embedded systems and firmware testing: hardware abstraction (HAL), mocking peripherals (ArduinoFake), host-based unit testing (GTest/GMock), and Hardware-in-the-Loop (HIL) patterns.
When to use me
- Testing firmware without physical hardware (native/host tests)
- Mocking hardware dependencies (GPIO, SPI, I2C, UART)
- Setting up HIL (Hardware-in-the-Loop) test suites
- Designing testable embedded architectures using HAL and DI
- Debugging timing-critical or peripheral integration issues
Core principles
- Test on Host First - Execute business logic on the development machine for fast feedback loops.
- HAL Abstraction - Separate hardware access from logic using interfaces to enable mocking.
- Dependency Injection - Inject hardware interfaces into devices to make them testable.
- Deterministic Timing - Use controlled clocks/delays in tests to avoid hardware-induced flakiness.
- HIL for Critical Paths - Reserve actual hardware tests for timing, peripherals, and integration.
Patterns & examples
Hardware Abstraction Layer (HAL):
// Logic depends on interface, not direct register access
class GPIOInterface {
public:
virtual void digitalWrite(uint8_t pin, uint8_t value) = 0;
};
class LED {
GPIOInterface* gpio;
public:
LED(GPIOInterface* g) : gpio(g) {}
void on() { gpio->digitalWrite(13, HIGH); }
};
Mocking with Google Mock:
class MockGPIO : public GPIOInterface {
public:
MOCK_METHOD(void, digitalWrite, (uint8_t pin, uint8_t value), (override));
};
TEST(LEDTest, TurnsOn) {
MockGPIO mock;
LED led(&mock);
EXPECT_CALL(mock, digitalWrite(13, HIGH)).Times(1);
led.on();
}
Hardware-in-the-Loop (HIL):
// Test frequency accuracy on real silicon
TEST(PWMTest, FrequencyAccuracy) {
PWMController pwm(PIN_PWM);
pwm.setFrequency(1000);
pwm.start();
// Measure actual period with hardware timers...
EXPECT_NEAR(measurePeriod(), 1000, 50); // 5% tolerance
}
Anti-patterns to avoid
- ❌ Direct Register Access in Logic - Makes code untestable without hardware.
- ❌ Testing via Serial/Printf - Slow, brittle, and non-automated (use GTest).
- ❌ Arbitrary Delays -
delay(100)makes tests slow and flaky; use event-based waiting. - ❌ Only Testing on Hardware - Slow feedback cycle; test logic on host first.
- ❌ Implementation Testing - Testing private methods instead of visible behaviour.
KB Reference
~/vaults/baphled/3. Resources/Knowledge Base/AI Development System/Skills/Testing-BDD/Embedded Testing.md
Related skills
cpp- Core C++ idioms and patternsplatformio- Build and test runner for embeddedbdd-workflow- Red-Green-Refactor cycleclean-code- SOLID for embedded systems
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?