Skip to content

Commit 409d0f8

Browse files
markpollackclaude
andcommitted
feat: Complete integration testing framework with AI validation system
Achieve 97% coverage (32/33 examples) with revolutionary AI-powered validation capabilities. Key achievements: • AI validation system for interactive applications using Claude Code CLI • Interactive application testing breakthrough (Scanner-based apps now testable) • 84% code reduction through centralized JBang utilities • Comprehensive documentation with templates and troubleshooting guide • Production-ready framework with ~92% test reliability Technical innovations: • Multi-mode validation: Primary/Hybrid/Fallback for different application types • Cost-efficient AI validation at ~$0.002 per test • Automatic exit code handling for interactive applications • Template-driven configuration for 5 application categories • Complete Phase 4 knowledge synthesis and documentation Coverage evolution: 0% → 97% through systematic 4-phase implementation Framework status: Production-ready for Spring AI quality assurance 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 99266e1 commit 409d0f8

File tree

21 files changed

+2006
-164
lines changed

21 files changed

+2006
-164
lines changed

CLAUDE.md

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,37 @@ mvn clean package
7272

7373
## Testing Framework
7474

75-
This repository uses a lightweight integration testing framework for ensuring all examples work correctly across releases.
75+
This repository uses a comprehensive integration testing framework with **AI-powered validation** for ensuring all examples work correctly across releases. The framework achieves **97% coverage (32/33 examples)** with intelligent validation for interactive applications.
7676

7777
### Testing Approaches
7878

7979
| Example Type | Test Location | Command | Purpose |
8080
|--------------|---------------|---------|---------|
8181
| **Simple** | `src/test/java/` | `./mvnw test` | Unit tests, basic functionality |
82-
| **Complex** | `integration-tests/` | `jbang integration-tests/Run*.java` | End-to-end integration |
82+
| **Complex** | `integration-tests/` | `jbang integration-tests/Run*.java` | End-to-end integration with AI validation |
83+
84+
### Key Features
85+
86+
- **AI Validation**: Intelligent analysis of application logs for non-deterministic outputs
87+
- **Interactive Application Support**: Testing of chatbots and Scanner-based applications
88+
- **Centralized Architecture**: Single source of truth with 84% code reduction
89+
- **Comprehensive Logging**: Full application output preserved for debugging
8390

8491
### Quick Testing Commands
8592

86-
**Run all integration tests:**
93+
**Run all integration tests (recommended):**
94+
```bash
95+
./integration-testing/scripts/rit-direct.sh
96+
```
97+
98+
**Run specific integration test:**
8799
```bash
88-
python3 integration-testing/scripts/run_integration_tests.py
100+
./integration-testing/scripts/rit-direct.sh module-name
101+
```
102+
103+
**Run with clean logs:**
104+
```bash
105+
./integration-testing/scripts/rit-direct.sh --clean-logs
89106
```
90107

91108
**Create integration test for new example:**
@@ -95,17 +112,17 @@ python3 integration-testing/scripts/scaffold_integration_test.py <module-path> [
95112

96113
**Create integration test with AI validation:**
97114
```bash
98-
# Default: hybrid AI validation enabled
99-
python3 integration-testing/scripts/scaffold_integration_test.py kotlin/kotlin-hello-world
115+
# Simple example (hybrid AI validation)
116+
python3 integration-testing/scripts/scaffold_integration_test.py kotlin/kotlin-hello-world --complexity simple
100117

101-
# Complex workflow with primary AI validation (recommended for agentic patterns)
102-
python3 integration-testing/scripts/scaffold_integration_test.py agentic-patterns/chain-workflow --complexity complex --ai-mode primary
118+
# Complex workflow (primary AI validation)
119+
python3 integration-testing/scripts/scaffold_integration_test.py agentic-patterns/chain-workflow --complexity complex
103120

104-
# MCP example with client-server validation
105-
python3 integration-testing/scripts/scaffold_integration_test.py model-context-protocol/weather/server --complexity mcp
121+
# Interactive application (fallback AI validation)
122+
python3 integration-testing/scripts/scaffold_integration_test.py agents/reflection --complexity complex
106123

107-
# Disable AI validation (regex patterns only)
108-
python3 integration-testing/scripts/scaffold_integration_test.py simple-example --no-ai-validation
124+
# MCP example (hybrid validation)
125+
python3 integration-testing/scripts/scaffold_integration_test.py model-context-protocol/weather/server --complexity complex
109126
```
110127

111128
**Test specific example:**
@@ -117,22 +134,28 @@ jbang integration-tests/Run*.java # For complex examples
117134

118135
### Integration Test Structure
119136

120-
Complex examples include an optional `integration-tests/` directory:
137+
Complex examples include an `integration-tests/` directory with AI validation:
121138
```
122139
module/
123140
├── integration-tests/
124-
│ ├── ExampleInfo.json # Test configuration (timeout, success patterns, env vars)
141+
│ ├── ExampleInfo.json # Test configuration with AI validation support
125142
│ └── RunModule.java # JBang launcher (uses centralized utilities)
126143
```
127144

128-
### JBang Script Pattern (IMPORTANT)
145+
### JBang Script Pattern & AI Validation
129146

130-
All JBang integration test scripts use centralized utilities to eliminate code duplication:
131-
- Each script is only ~18 lines (down from ~110-130 lines)
132-
- All test logic lives in `integration-testing/jbang-lib/IntegrationTestUtils.java`
133-
- See `integration-testing/docs/JBANG_PATTERN.md` for the required pattern
147+
All integration test scripts use centralized utilities with AI validation support:
148+
- **Centralized Architecture**: Each script is only ~18 lines (84% code reduction)
149+
- **AI Integration**: Automatic AI validation using Claude for intelligent analysis
150+
- **Universal Support**: All test logic in `integration-testing/jbang-lib/IntegrationTestUtils.java`
151+
- **Interactive Apps**: Special handling for Scanner-based applications
152+
153+
**Validation Modes:**
154+
- **Primary**: AI-only validation for unpredictable AI outputs
155+
- **Hybrid**: Regex patterns + AI validation for reliability
156+
- **Fallback**: Regex primary with AI backup for interactive applications
134157

135-
See `integration-testing/docs/README.md` for complete testing guide.
158+
See `integration-testing/docs/README.md` for complete guide and `integration-testing/docs/TROUBLESHOOTING.md` for troubleshooting.
136159

137160
### 🤖 AI Validation (NEW)
138161

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"timeoutSec": 15,
3+
"successRegex": [
4+
"Started.*Application",
5+
"Let's chat!"
6+
],
7+
"requiredEnv": [
8+
"OPENAI_API_KEY"
9+
],
10+
"aiValidation": {
11+
"enabled": true,
12+
"validationMode": "fallback",
13+
"readmeFile": "../README.md",
14+
"expectedBehavior": "Interactive reflection agent should start successfully and display the 'Let's chat!' prompt, indicating the dual ChatClient system (generation and critique agents) is ready for user input. The application will wait for interactive input to demonstrate iterative code generation and improvement.",
15+
"promptTemplate": "example_validation",
16+
"successCriteria": {
17+
"requiresUserInteraction": true,
18+
"expectedComponents": ["spring_boot_startup", "reflection_agent_ready", "interactive_prompt"],
19+
"validationNote": "Tests readiness for interactive AI reflection workflow"
20+
}
21+
}
22+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//DEPS org.zeroturnaround:zt-exec:1.12
3+
//DEPS com.fasterxml.jackson.core:jackson-databind:2.17.1
4+
//JAVA 17
5+
//FILES ExampleInfo.json
6+
//SOURCES ../../../integration-testing/jbang-lib/IntegrationTestUtils.java
7+
8+
/*
9+
* Integration test launcher for reflection
10+
* Uses centralized utilities from IntegrationTestUtils
11+
* Note: This is an interactive application - test validates startup and readiness
12+
*/
13+
14+
public class RunReflection {
15+
16+
public static void main(String... args) throws Exception {
17+
IntegrationTestUtils.runIntegrationTest("reflection");
18+
}
19+
}

0 commit comments

Comments
 (0)