This plugin embraces Contract-Based Testing as a first-class paradigm. The contract defines the expected behavior of your service β and tests should derive from it automatically.
| Contract Type | Status | Description |
|---|---|---|
| OpenAPI / Swagger | β Stable | REST API specifications (YAML/JSON) |
| gRPC Protobuf | π Planned | Protocol Buffer service definitions |
| Java Interface | π Planned | Java class/interface contracts |
| GraphQL Schema | π Future | GraphQL type definitions |
The plugin is architected to be extensible β adding a new contract type requires implementing a new parser and prompt template.
- Contract-First Testing β Tests are generated from the contract, not the implementation
- Multi-Framework Support β JUnit 5 + Rest Assured or Karate DSL
- AI-Powered β Leverages any OpenAI-compatible LLM endpoint
- Comprehensive Coverage β Generates happy path + negative test cases
- IDE Integration β Seamless notification banner on contract files
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CONTRACT β
β (OpenAPI / Protobuf / ...) β
β β SOURCE OF TRUTH β
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Test Generator Plugin β
β (context-aware prompt engineering) β
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TESTS β
β Rest Assured / Karate / JUnit / Spock ... β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The contract is:
- Single source of truth β No duplication between spec and tests
- Version-controlled β Contract changes trigger test regeneration
- Language-agnostic β Works with any test framework
ai-test-plugin/
βββ core/ # Contract-agnostic core
β βββ GenerationRequest.kt
β βββ PromptBuilder.kt # LLM prompt construction
β βββ Framework.kt # Test framework abstractions
βββ llm-client/ # OpenAI-compatible LLM client
β βββ OpenAiCompatibleProvider.kt
βββ plugin-idea/ # IntelliJ IDEA plugin
βββ GenerateTestsDialog.kt # UI configuration
βββ GenerateTestsService.kt # Test generation orchestration
βββ contracts/ # Contract type handlers
βββ openapi/ # OpenAPI parser & heuristics
- Open IntelliJ IDEA 2025.2+
- Go to Settings β Plugins
- Search for "AI Test Generator"
- Install and restart IDE
Download the latest release from GitHub Releases and install via Settings β Plugins β Install Plugin from Disk.
Create or edit ai-test-config.yaml in your project root:
llm:
endpoint: "https://api.openai.com/v1/chat/completions"
apiKey: "${OPENAI_API_KEY}"
model: "gpt-4o"
generation:
defaultFramework: "restassured"
defaultClassName: "ApiTest"
defaultBaseUrl: "http://localhost:8080"
defaults:
restassured:
packageName: "com.example.tests"
location: "src/test/java"
karate:
location: "src/test/kotlin"OPENAI_API_KEY- Your OpenAI API key (or any OpenAI-compatible provider)- Use
${ENV_VAR}syntax in config for secrets
- Open any contract file (
.yaml,.jsonfor OpenAPI) - A notification banner appears: "Generate Tests?"
- Click to open the generation dialog
- Configure:
- Framework - JUnit 5 + Rest Assured or Karate DSL
- Location - Output directory
- Class Name - Test class/feature name
- Base URL - Optional API base URL hint
- Extra Instructions - Additional context for the LLM
- Click Generate
The plugin analyzes the contract and generates:
- Happy path tests for each operation/endpoint
- Negative tests for missing required fields
- Boundary/type validation tests
package com.example.tests;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.*;
import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
public class UserApiTest {
@BeforeAll
public static void setup() {
RestAssured.baseURI = "http://localhost:8080";
}
@Test
void getUser_Success() {
given()
.pathParam("id", 1)
.when()
.get("/users/{id}")
.then()
.statusCode(200)
.contentType(ContentType.JSON)
.body("id", equalTo(1))
.body("name", notNullValue());
}
@Test
void getUser_NotFound() {
given()
.pathParam("id", 99999)
.when()
.get("/users/{id}")
.then()
.statusCode(404);
}
}Feature: User API Contract Tests
Background:
* url baseUrl || 'http://localhost:8080'
Scenario: Get user - success
Given path 'users', 1
When method get
Then status 200
And match response == { id: 1, name: '#notnull', email: '#regex[.*@.*]' }
Scenario: Get user - not found
Given path 'users', 99999
When method get
Then status 404
And match response == { code: '#notnull', message: '#string' }- IntelliJ IDEA 2025.2+ (for development)
- JDK 17+
- Gradle 9.x
# Build the plugin JAR
./gradlew :plugin-idea:buildPlugin
# Build with ZIP distribution
./gradlew :plugin-idea:assemble
# Run in development IDE
./gradlew :plugin-idea:runIde# Publish to Maven Local
./gradlew :plugin-idea:publishPluginZipPublicationToMavenLocal
# Publish to Sonatype (requires credentials)
./gradlew :plugin-idea:publishPluginDistributionPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository- gRPC Protobuf support β Generate tests from
.protofiles - Java Interface contracts β Generate tests from annotated interfaces
- Contract diff detection β Alert when contract changes affect existing tests
- Test regeneration β Smart update instead of full overwrite
Contributions are welcome! Key areas:
- New contract type parsers (gRPC, GraphQL, Java)
- Additional test framework generators (Spock, TestNG)
- LLM prompt optimization
Licensed under the Apache License 2.0 - see LICENSE for details.
Built with β€οΈ for the contract-driven testing community
