C/C++ Test Automation with Claude Code and Cantata
The manual overhead of C/C++ unit testing remains one of the most persistent bottlenecks in high-integrity software development. In certified environments, achieving full structural coverage (statement, decision, MC/DC) can consume a significant portion of engineering time, often requiring hours or days of manual setup, stub configuration, and iterative debugging.
Recent advances in AI-assisted development introduce a different approach.
With Cantata 26.01, a Claude Code Skill enables an agentic workflow where AI does not simply suggest code but actively participates in the unit testing process. Instead of acting as a passive assistant, the AI can orchestrate test generation, execution, and refinement in a structured, repeatable loop.
This shifts the effort from manual scaffolding to guided verification.
From Code Suggestion to Test Automation Workflow
Traditional LLM usage in testing focuses on generating example test cases. However, in safety-critical development, test generation alone is insufficient. What matters is the full lifecycle:
- generating tests
- executing them in a controlled environment
- measuring coverage using a qualified tool
- identifying gaps
- iterating until targets are met
Rather than relying on static outputs, the AI operates within a closed-loop workflow:
- Analyse
The AI inspects the C/C++ source, identifying decision points, dependencies, and testable paths. - Generate
Test cases are created with explicit coverage targets (e.g. decision or MC/DC coverage), including boundary and edge conditions. - Integrate & Execute
Tests are compiled and executed within the Cantata environment. - Measure
Coverage is measured using Cantata’s qualified tooling, not the AI. - Iterate
Coverage gaps are identified and fed back into the generation step, producing targeted follow-up tests.
This generate → measure → gap-fill → repeat cycle is where the real efficiency gains are realised.
Human-in-the-Loop: A Required Design Principle
AI-assisted testing does not remove the need for engineering judgement, instead it makes it more focused.
A critical distinction in safety-critical workflows is that:
- The AI acts as an authoring assistant
- Cantata provides verification evidence
- The engineer remains accountable for correctness
AI-generated tests can be syntactically valid yet assert incorrect behaviour. This is a known risk (often referred to as hallucination), and it reinforces the need for structured review.
In practice, this leads to a review-gated workflow, where:
- Generated tests are inspected before integration
- Coverage results are validated against expectations
- Traceability is maintained from requirement → test → coverage evidence
This model aligns with standards such as DO-178C, ISO 26262, and IEC 62304, where the method of test creation is secondary to verification and evidence.
Practical Considerations for Adoption
Introducing AI into certified environments requires tooling and governance.
Key considerations include:
- Technical risk
AI may generate correct-looking but incorrect tests → requires review discipline - Data security
Source code shared with LLMs must comply with organisational and contractual constraints - Skill retention
Engineers must continue to understand and validate test design, not rely blindly on generated output - Traceability and auditability
Teams must record where AI was used, what was generated, and who reviewed it
A practical approach is incremental adoption:
- Start with a non-safety-critical module
- Compare effort vs manual testing
- Measure coverage improvement and defect detection
- Expand gradually into safety-relevant areas
Early deployments of AI-assisted workflows in embedded systems show measurable improvements:
- 40%+ reduction in test creation time
- Up to 98% structural coverage achieved in complex codebases
- Detection of previously unknown defects during test generation
These gains are achieved without compromising certification requirements, as verification remains grounded in qualified tooling and human review.
A Shift in Engineering Focus
AI-assisted unit testing redistributes the complexity of testing.
Instead of spending time on:
- scaffolding test environments
- writing repetitive boilerplate
- manually chasing coverage gaps
Engineers can focus on:
- validating behaviour
- ensuring requirement alignment
- maintaining system-level integrity
The result is a more controlled and repeatable process for achieving coverage in safety-critical software.
Requirements for Deployment
- Cantata version 26.01 or later
- Python 3 and supported C/C++ compiler (e.g. GCC/G++)
From Manual to AI Assisted: Practical Automation of Unit Test Generation in Safety-Critical Systems
This demo video demonstrates the concepts discussed in this article through a full end-to-end workflow, based on real techniques from Embedded Software Testing: From Fundamentals to AI. It walks through a practical approach to using AI for unit test generation in safety-critical environments, showing how it can be implemented in real development pipelines. The focus is on evidence rather than theory, illustrating how AI-assisted testing can accelerate test creation while maintaining certification requirements and engineering control.

