Contract-Driven Requirement Coverage for Java
Prathya is an open-source Java tool that brings formal requirement traceability to software testing. It treats requirements as first-class, versioned artifacts, links tests to those requirements via annotations, and measures requirement coverage — a more meaningful quality signal than code coverage alone.
Code coverage tells you what was touched. Requirement coverage tells you whether intent was verified.
Prathya introduces Contract-Driven Development (CDD) as a natural companion to established methodologies:
| Methodology | Focus | Gap |
|---|---|---|
| TDD | Write the test first, then the code | Drives implementation but says nothing about whether the tests are the right tests |
| BDD | Write behavior specifications in natural language | Improves communication but doesn't enforce traceability or coverage measurement |
| CDD | Define the contract first. Tests are written against the contract | The contract is the source of truth — not the code, not the tests, not a ticket |
JaCoCo measures code coverage — which lines, branches, and paths were executed. Prathya measures requirement coverage — which documented requirements have tests mapped to them. JaCoCo tells you what code ran. Prathya tells you what requirements were verified. They're complementary, and together they form a two-signal model:
- Requirement coverage low — your module is not verified against its own contract. Code coverage is irrelevant here — unverified requirements are unverified regardless.
- Requirement coverage high, code coverage low — contract tests exist but aren't exercising the code. Tests may be too shallow, dead code may exist, or the contract doesn't reflect the full scope of the module.
- Both high — intent is verified and the code backing it is exercised. Nothing is hiding.
Why this matters for vibe coding: LLMs generate code fast but rarely clean up after themselves. Dead code accumulates silently as features get rewritten mid-conversation. Prathya signals the gap — code that no requirement accounts for — so you can direct the LLM to clean up what it left behind.
<dependency>
<groupId>com.intrigsoft.prathya</groupId>
<artifactId>prathya-annotations</artifactId>
<version>0.6.1</version>
<scope>test</scope>
</dependency>module:
id: AUTH
name: Auth Service
description: Handles user authentication
requirements:
- id: AUTH-001
version: 1.0.0
status: approved
title: User login with valid credentials
description: >
The system must authenticate a user given valid credentials,
returning a signed JWT.
acceptance_criteria:
- Returns HTTP 200 with a JWT in the response body
corner_cases:
- id: AUTH-001-CC-001
description: Invalid password — must return 401import com.intrigsoft.prathya.annotations.Requirement;
class AuthServiceTest {
@Test
@Requirement("AUTH-001")
void login_validCredentials_returnsJwt() {
// ...
}
@Test
@Requirement("AUTH-001-CC-001")
void login_wrongPassword_returns401() {
// ...
}
}mvn clean verifyPrathya runs after tests complete and produces an HTML report at target/prathya/index.html and a JSON report at target/prathya/prathya-report.json.
plugins {
id("com.intrigsoft.prathya.gradle") version "0.6.1"
}
dependencies {
testImplementation("com.intrigsoft.prathya:prathya-annotations:0.6.1")
}./gradlew prathyaVerifySee the Gradle Plugin docs for configuration and available tasks.
Prathya includes an MCP server that lets AI coding agents participate directly in the contract-driven development loop — reading the contract, checking coverage, and iterating until it's satisfied.
Add it to your MCP configuration with JBang:
{
"mcpServers": {
"prathya": {
"command": "jbang",
"args": [
"--quiet",
"--main", "com.intrigsoft.prathya.mcp.PrathyaMcpServer",
"com.intrigsoft.prathya:prathya-mcp-server:0.6.1"
]
}
}
}Full documentation at intrigsoft.github.io/prathya:
- Concepts — understand Contract-Driven Development in depth
- CONTRACT.yaml Reference — full schema and field reference
- Maven Plugin — setup, goals, and configuration
- Gradle Plugin — Gradle integration
- MCP Server — AI agent integration via Model Context Protocol
- Audit Rules — what Prathya checks and how to configure it
