<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/test-your-llm-apps-like-the-rest-of-your-java-code-hzgz5uwda" -->

---
title: Test your LLM apps like the rest of your Java code
description: Rage4J is a Java library for testing LLM applications, such as RAG pipelines and AI agents, using a familiar given/when/then JUnit-style structure. It provides...
canonical: https://daily.dev/posts/test-your-llm-apps-like-the-rest-of-your-java-code-hzgz5uwda
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Test your LLM apps like the rest of your Java code | daily.dev
og:description: Rage4J is a Java library for testing LLM applications, such as RAG pipelines and AI agents, using a familiar given/when/then JUnit-style structure. It provides...
og:url: https://daily.dev/posts/test-your-llm-apps-like-the-rest-of-your-java-code-hzgz5uwda
og:image: https://api.daily.dev/og/posts/HzgZ5UwDa.png
og:image:alt: Test your LLM apps like the rest of your Java code
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Test your LLM apps like the rest of your Java code

**[Awesome Java Newsletter](https://daily.dev/sources/java_libhunt)** · 2 min read · 1 upvotes · 0 comments

## Summary

Rage4J is a Java library for testing LLM applications, such as RAG pipelines and AI agents, using a familiar given/when/then JUnit-style structure. It provides metrics like answer correctness, faithfulness, answer relevance, semantic similarity, tool call accuracy, and BLEU/ROUGE scores. It builds on LangChain4j and integrates with any model provider such as OpenAI or Ollama. The library ships as modular Maven Central artifacts (core, assert, persist, persist-junit5), and it's currently at version 2.0.2.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://rage4j.dev/>

## Questions this post answers

### How can I test a RAG pipeline or LLM agent using JUnit in Java?

Rage4J provides a given/when/then JUnit-style API for testing LLM apps: given() describes the question, expected answer, and context or tool calls; when() calls your app via any function, including a LangChain4j AI service or REST client; then() asserts score thresholds on metrics so regressions fail the build. It builds on LangChain4j and is available on Maven Central as rage4j-assert.

_Developers wiring LLM quality checks into CI find library and framework updates like this on daily.dev._

### What metrics can I use to evaluate LLM answer quality in automated tests?

Rage4J supports answer correctness, faithfulness, answer relevance, semantic similarity, tool call accuracy, and BLEU/ROUGE scores. Answer correctness and faithfulness use an LLM judge to compare claims against ground truth and given context; semantic similarity uses embedding distance; tool call accuracy and BLEU/ROUGE are deterministic n-gram or LCS overlap scores, fast and free to run.

_Teams comparing evaluation metrics for LLM outputs track library options like this on daily.dev._

## Similar posts on daily.dev

- [foojay – a place for friends of OpenJDK](https://daily.dev/posts/foojay-a-place-for-friends-of-openjdk-vke1bkzad) · Foojay.io · 0 upvotes · 0 comments
- [Java\+LLMs: A hands-on guide to building LLM Apps in Java](https://daily.dev/posts/java-llms-a-hands-on-guide-to-building-llm-apps-in-java-fqwk6wrd9) · Shaaf · 2 upvotes · 0 comments
- [Spring AI 2.0 in Practice: Adding LLM Features to a Java Web App](https://daily.dev/posts/spring-ai-2-0-in-practice-adding-llm-features-to-a-java-web-app-kqfaxawkj) · Vaadin · 1 upvotes · 0 comments

---

Tags: [#java](https://daily.dev/tags/java), [#langchain4j](https://daily.dev/tags/langchain4j)

[View this post on daily.dev](https://daily.dev/posts/test-your-llm-apps-like-the-rest-of-your-java-code-hzgz5uwda)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Test your LLM apps like the rest of your Java code","url":"https://daily.dev/posts/test-your-llm-apps-like-the-rest-of-your-java-code-hzgz5uwda","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/test-your-llm-apps-like-the-rest-of-your-java-code-hzgz5uwda"},"datePublished":"2026-09-17T20:55:53.458Z","dateModified":"2026-09-17T22:37:14.937Z","description":"Rage4J is a Java library for testing LLM applications, such as RAG pipelines and AI agents, using a familiar given/when/then JUnit-style structure. It provides...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a34bdf9326d2088bcdfaa71f04dc5db7?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a34bdf9326d2088bcdfaa71f04dc5db7?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Awesome Java Newsletter","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Awesome Java Newsletter","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/7729929f2ca649d7b13f6b04aa94d300","url":"https://daily.dev/sources/java_libhunt"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/test-your-llm-apps-like-the-rest-of-your-java-code-hzgz5uwda","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"java,langchain4j","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Awesome Java Newsletter","item":"https://daily.dev/sources/java_libhunt"},{"@type":"ListItem","position":3,"name":"Test your LLM apps like the rest of your Java code"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/test-your-llm-apps-like-the-rest-of-your-java-code-hzgz5uwda#faq","mainEntity":[{"@type":"Question","name":"How can I test a RAG pipeline or LLM agent using JUnit in Java?","acceptedAnswer":{"@type":"Answer","text":"Rage4J provides a given/when/then JUnit-style API for testing LLM apps: given() describes the question, expected answer, and context or tool calls; when() calls your app via any function, including a LangChain4j AI service or REST client; then() asserts score thresholds on metrics so regressions fail the build. It builds on LangChain4j and is available on Maven Central as rage4j-assert. Developers wiring LLM quality checks into CI find library and framework updates like this on daily.dev."}},{"@type":"Question","name":"What metrics can I use to evaluate LLM answer quality in automated tests?","acceptedAnswer":{"@type":"Answer","text":"Rage4J supports answer correctness, faithfulness, answer relevance, semantic similarity, tool call accuracy, and BLEU/ROUGE scores. Answer correctness and faithfulness use an LLM judge to compare claims against ground truth and given context; semantic similarity uses embedding distance; tool call accuracy and BLEU/ROUGE are deterministic n-gram or LCS overlap scores, fast and free to run. Teams comparing evaluation metrics for LLM outputs track library options like this on daily.dev."}}]}
```

