Comprehensive testing strategies for LangChain4j applications with mocks, containers, and RAG validation.
Works with
Provides unit testing patterns with mock models, integration testing via Testcontainers, and end-to-end workflows for RAG systems, AI Services, and tool execution
Covers testing pyramid approach: 70% unit tests with mocks, 20% integration tests with real services, 10% end-to-end tests
Includes specialized patterns for streaming responses, memory management, guardrail assertions,
AI-first code editor with Composer
Before installing skills in Cursor, ensure your development environment meets these requirements:
node --versionlangchain4j-testing-strategiesExecute the skills CLI command in your project's root directory to begin installation:
Fetches langchain4j-testing-strategies from giuseppe-trisciuoglio/developer-kit and configures it for Cursor.
The CLI shows a list of agents. Use arrow keys and space to select Cursor:
Confirm successful installation by checking the skill directory location:
Restart Cursor to activate langchain4j-testing-strategies. Access via /langchain4j-testing-strategies in your agent's command palette.
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Submit your Claude Code skill and start earning
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
0
total installs
0
this week
194
GitHub stars
0
upvotes
Run in your terminal
0
installs
0
this week
194
stars
Patterns for unit testing with mocks, integration testing with Testcontainers, and end-to-end validation of RAG systems, AI Services, and tool execution.
Use mock models for fast, isolated testing. See references/unit-testing.md.
ChatModel mockModel = mock(ChatModel.class);
when(mockModel.generate(any(String.class)))
.thenReturn(Response.from(AiMessage.from("Mocked response")));
var service = AiServices.builder(AiService.class)
.chatModel(mockModel)
.build();
Setup Maven/Gradle dependencies. See references/testing-dependencies.md.
langchain4j-test - Guardrail assertionstestcontainers - Containerized testingmockito - Mock external dependenciesassertj - Fluent assertionsTest with real services. See references/integration-testing.md.
@Testcontainers
class OllamaIntegrationTest {
@Container
static GenericContainer<?> ollama = new GenericContainer<>(
DockerImageName.parse("ollama/ollama:0.5.4")
).withExposedPorts(11434);
@Test
void shouldGenerateResponse() {
// Verify container is healthy
assertTrue(ollama.isRunning());
await().atMost(30, TimeUnit.SECONDS)
.until(() -> ollama.getLogs().contains("API server listening"));
ChatModel model = OllamaChatModel.builder()
.baseUrl(ollama.getEndpoint())
.build();
// Verify model responds before running tests
assertDoesNotThrow(() -> model.generate("ping"));
String response = model.generate("Test query");
assertNotNull(response);
}
}
Streaming, memory, error handling patterns in references/advanced-testing.md.
Follow the testing pyramid from references/workflow-patterns.md:
70% Unit Tests ─ Mock ChatModel, guardrails, edge cases
20% Integration Tests ─ Testcontainers, vector stores, RAG
10% End-to-End Tests ─ Complete user journeys
@Timeout duration for slow models, check container resource limits@Test
void shouldProcessQueryWithMock() {
ChatModel mockModel = mock(ChatModel.class);
when(mockModel.generate(any(String.class)))
.thenReturn(Response.from(AiMessage.from("Test response")));
var service = AiServices.builder(AiService.class)
.chatModel(mockModel)
.build();
String result = service.chat("What is Java?");
assertEquals("Test response", result);
}
@Testcontainers
class RAGIntegrationTest {
@Container
static GenericContainer<?> ollama = new GenericContainer<>(
DockerImageName.parse("ollama/ollama:0.5.4")
);
@BeforeAll
static void waitForContainerReady() {
await().atMost(60, TimeUnit.SECONDS)
.until(() -> ollama.getLogs().contains("API server listening"));
}
@Test
void shouldCompleteRAGWorkflow() {
assertTrue(ollama.isRunning());
var chatModel = OllamaChatModel.builder()
.baseUrl(ollama.getEndpoint())
.build();
var embeddingModel = OllamaEmbeddingModel.builder()
.baseUrl(ollama.getEndpoint())
.build();
var store = new InMemoryEmbeddingStore<>();
var retriever = EmbeddingStoreContentRetriever.builder()
.chatModel(chatModel)
.embeddingStore(store)
.embeddingModel(embeddingModel)
.build();
var assistant = AiServices.builder(RagAssistant.classPrerequisites
Time Estimate
15-45 minutes depending on use case complexity
Steps
Common Pitfalls
✓ Do
✗ Don't
💡 Pro Tips
✓ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
giuseppe-trisciuoglio/developer-kit
giuseppe-trisciuoglio/developer-kit
giuseppe-trisciuoglio/developer-kit
giuseppe-trisciuoglio/developer-kit
samber/cc-skills-golang
aj-geddes/useful-ai-prompts
I recommend langchain4j-testing-strategies for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
Useful defaults in langchain4j-testing-strategies — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
Solid pick for teams standardizing on skills: langchain4j-testing-strategies is focused, and the summary matches what you get after install.
langchain4j-testing-strategies is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
langchain4j-testing-strategies has been reliable in day-to-day use. Documentation quality is above average for community skills.
Keeps context tight: langchain4j-testing-strategies is the kind of skill you can hand to a new teammate without a long onboarding doc.
langchain4j-testing-strategies fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
langchain4j-testing-strategies fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
We added langchain4j-testing-strategies from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
langchain4j-testing-strategies has been reliable in day-to-day use. Documentation quality is above average for community skills.
showing 1-10 of 47