add-test-with-mock

Create JUnit 5 and Kotlin Test unit tests with mock objects for KAgentic components.

1|Updated Jul 28, 2025
One-click install
npx skills add https://github.com/anoopg87/KAgentic --skill add-test-with-mock
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-test-with-mock
Source: https://github.com/anoopg87/KAgentic/tree/main/.claude/skills/add-test-with-mock
Command: npx skills add https://github.com/anoopg87/KAgentic --skill add-test-with-mock

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Reduce fragile or incomplete test coverage by providing clear patterns, mock implementations, and examples to quickly produce reliable unit tests for KAgentic components.

Core Features & Use Cases

  • Patterned examples for testing Tools, LLM providers, AgentFramework, ConversationMemory, and agent graphs.
  • Mock object recipes and factories for LLMs, tools, memory, HTTP clients, and stateful behaviors to isolate dependencies.
  • Async and coroutine testing techniques using runBlocking, timeout handling, and coverage/run instructions for Gradle.
  • Use case: scaffold tests for a new LLM provider, validate tool selection and scoring, or simulate transient API failures to verify retry logic.

Quick Start

Create a unit test scaffold that uses a mock LLM and a mock tool to verify tool selection and response handling, then run the tests with Gradle.

Frequently Asked Questions about add-test-with-mock

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

FAQPage Schema
How do I write unit tests for Kotlin coroutines and suspend functions?

Unit testing suspend functions requires wrapping test code in runBlocking to manage coroutine execution. You can verify asynchronous behavior, handle timeouts, and validate error paths using JUnit 5 patterns.

How do I mock LLM providers and tools for agent unit tests?

Mocking LLM providers and tools involves creating object expressions or mock factories that simulate stateful behaviors and API responses. This isolates dependencies to verify tool selection, scoring, and response handling.

What is the best way to test agent graph behavior and conversation memory?

Testing agent graphs and conversation memory uses mock implementations to simulate interactions and state changes. Patterned examples validate memory strategies and agent framework routing without hitting live external endpoints.

Can I verify retry logic and transient API failures in JUnit 5?

Yes, you can simulate transient API failures using mock objects to verify retry logic and error handling paths. JUnit 5 supports asserting call counts and specific exception throwing to ensure robustness against failures.

How do I run Kotlin unit tests with coverage reporting in Gradle?

Running Kotlin unit tests with coverage reporting in Gradle involves executing the test task with the appropriate JaCoCo plugin configuration. This generates reports verifying test coverage for tools, agents, and memory components.