Spring Test Generator for VS Code
Automatically generate unit and integration tests for Spring Boot applications directly in VS Code.
Features
- Generate Tests: Automatically generate unit and integration tests for Spring Boot classes
- Analyze Spring Classes: Analyze and display all Spring Boot components in your project
- Configurable: Customize test generation with various options
Requirements
- Java 17 or higher
- Maven project with Spring Test Generator CLI JAR built
- VS Code 1.80.0 or higher
Installation
Build the Spring Test Generator CLI JAR:
mvn clean package -pl core,cli
Install the VS Code extension (development mode):
cd ide-integration/vscode
npm install
npm run compile
Press F5 in VS Code to launch Extension Development Host
Usage
Generate Tests
- Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
- Run command: "Spring Test Generator: Generate Tests"
- Tests will be generated in the configured output directory
- Choose to open generated files
Analyze Spring Classes
- Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
- Run command: "Spring Test Generator: Analyze Spring Classes"
- View results in the Output channel
Configuration
Open VS Code Settings and search for "Spring Test Generator":
springTestGenerator.sourceDirectory: Source code directory (default: src/main/java)
springTestGenerator.outputDirectory: Test output directory (default: src/test/java)
springTestGenerator.testType: Type of tests to generate - unit, integration, or all (default: all)
springTestGenerator.namingStrategy: Test naming strategy - method-scenario, bdd, or given-when-then (default: method-scenario)
springTestGenerator.cliJarPath: Path to CLI JAR (auto-detected if empty)
Commands
springTestGen.generate: Generate tests for Spring Boot classes
springTestGen.analyze: Analyze and display Spring Boot classes
Development
Build the extension:
npm run compile
Watch mode for development:
npm run watch
License
This extension is part of the Spring Test Generator project.
| |