Welcome to 2025! As we kick off a new year, it’s the perfect time to share Typemock’s latest innovation: the AI-Aware Isolator++ API. Following our recent post on AI-Aware Websites, we’re now taking the concept further to help developers and AI tools generate accurate C++ unit tests faster and with better results.
At Typemock, we believe that 2025 will be the year of advancing the AI-assisted coding, and we’re leading the way by ensuring that both human developers and AI tools can easily understand and work with our Isolator++ API.
Let’s dive into how we’ve structured our AI-Aware API documentation, the results we’ve seen, and how you can get started using AI-friendly prompts to write smarter unit tests.
Why Make APIs AI-Aware?
In today’s fast-paced development world, AI tools like ChatGPT, GitHub Copilot, and others have become integral to coding. Developers are turning to these tools for quick code generation and test automation, but there’s a catch — most APIs aren’t structured to provide AI with the context it needs to generate accurate, compilable code.
Traditional APIs are designed with human readability in mind, but AI tools need bulk, structured content to understand context and generate meaningful outputs. By creating AI-aware APIs, we ensure that AI-driven code generation is more effective and requires fewer prompts to get the job done.
Introducing the AI-Ready Isolator++ API
Our newly launched AI-Ready Isolator++ API is designed to make it easier for Large Language Models (LLMs) to generate accurate, compilable unit tests using Typemock’s powerful C++ mocking framework.
🔗 Check out our AI-Ready Isolator++ API documentation:
👉 https://www.typemock.com/docs/?book=Ipp&page=llm.htm
How It Works:
- Structured Documentation for AI Tools:
We’ve optimized the API docs to provide bulk text descriptions and detailed API summaries, which AI tools can consume and process easily. - AI-Friendly Prompts:
The documentation includes clear instructions on how to generate C++ unit tests using Typemock’s Isolator++ framework, ensuring that LLMs understand the exact macros and APIs needed. - Complex Mocking Scenarios:
Our documentation includes examples of how to mock static functions, private methods, and more advanced use cases that typically require manual intervention when using traditional APIs.
Prompt for AI Code Generation
To get the most out of the AI-Aware Isolator++ API, we recommend using the following prompt with AI tools like ChatGPT or Copilot:
Prompt:
You are an expert Typemock Developer with a deep understanding of GoogleTest and Typemock Isolator++.
Please open the Typemock Isolator++ API summary from www.typemock.com/docs/?book=Ipp&page=llm.htm. Using the API details described there, generate C++ unit tests for the attached class.Generate C++ unit test for the attached class.
The test should meet the following specifications:
Frameworks: Use GoogleTest for testing and Typemock for mocking.
Code Coverage: Include multiple tests for comprehensive coverage.
Structure: Provide full, compilable C++ code, including necessary using statements.
Make sure to follow the Typemock APIs and macros exactly as summarized in the referenced file.
Example Output from the AI Prompt
Here’s what you can expect from the AI-generated C++ code using the prompt above:
Sample Class:
1 2 3 4 5 6 7 |
class Calculator { public: static int Add(int a, int b) { SomeDependancy::Send("Adding"); return a + b; } }; |
AI-Generated Unit Test:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
#include <Isolator.h> #include "Calculator.h" #include <gtest/gtest.h> // Test Fixture Class class CalculatorTest : public ::testing::Test { protected: void TearDown() override { // Clean up ISOLATOR_CLEANUP(); } }; // Test Case: Add two positive numbers TEST_F(CalculatorTest, Add_TwoPositiveNumbers_ReturnsCorrectSum) { // Arrange int a = 5; int b = 7; int expectedSum = 12; WHEN_CALLED(SomeDependancy::Send(_)).Return(); // Act int result = Calculator::Add(a, b); // Assert EXPECT_EQ(result, expectedSum); VERIFY_CALLED(SomeDependancy::Send(_)).With("Adding"); } // Test Case: Add positive and negative numbers TEST_F(CalculatorTest, Add_PositiveAndNegativeNumbers_ReturnsCorrectSum) { // Arrange int a = 10; int b = -3; int expectedSum = 7; WHEN_CALLED(SomeDependancy::Send(_)).Return(); // Act int result = Calculator::Add(a, b); // Assert EXPECT_EQ(result, expectedSum); VERIFY_CALLED(SomeDependancy::Send(_)).With("Adding"); } |
This generated test is a fully compilable C++ unit test that uses the Typemock Isolator++ APIs and follows the Arrange-Act-Assert pattern.
The Results: AI-Aware API vs. Traditional Docs
We conducted a series of tests to compare the effectiveness of using traditional documentation versus our AI-Aware API documentation:
Metric | Traditional Docs | AI-Aware Docs |
---|---|---|
Prompts for Compilable Code | 3.2 prompts | 1.5 prompts |
Code Coverage | 70% | 85% |
Advanced Mocking Support | Limited | Comprehensive |
Key Takeaways:
✅ Fewer Prompts Needed: Developers using the AI-aware docs required less than half the prompts to generate compilable unit tests.
✅ Higher Code Coverage: AI-generated tests based on the AI-aware documentation covered more complex API scenarios.
✅ Advanced Mocking Support: The AI was able to handle complex mocking scenarios with ease.
What’s New in the AI-Aware Isolator++ API?
Here’s a quick look at some of the new capabilities we’ve added to the AI-optimized Isolator++ API:
Feature | Description |
---|---|
Advanced Mocking API | Easily mock static, global, and private functions. |
C++ Template Support | AI can now generate code using complex templates. |
Seamless Arrange-Act-Assert | Ensure clean, maintainable tests using the Arrange-Act-Assert pattern. |
Error-Free Compilation | AI-generated code compiles on the first try. |
Get Started with AI-Aware APIs Today!
The future of unit testing is here, and it’s AI-driven. By making your APIs AI-aware, you empower both human developers and AI tools to generate clean, maintainable code faster and with greater accuracy.
🔗 Explore the AI-Ready Isolator++ API documentation now:
👉 https://www.typemock.com/docs/?book=Ipp&page=llm.htm
Let us know your thoughts, and stay tuned for more updates from Typemock as we continue to innovate in the world of C++ unit testing and mocking frameworks.