AI-powered automatic test case generation for Java and Kotlin projects with Web UI and CLI
Project description
Universal Tester - AI-Powered Test Generation
Automatically generate high-quality JUnit tests for Java and Kotlin projects using AI.
Universal Tester leverages Large Language Models (LLMs) to understand your code and create comprehensive test suites with proper mocking, assertions, and edge case coverage. It comes with both a Command-Line Interface (CLI) and a Web UI for maximum flexibility.
๐ Features
- โ Multi-LLM Support: Azure OpenAI, Google Gemini, Ollama
- โ Smart Import Detection: Automatic dependency analysis and import management
- โ Two Interfaces: CLI for automation, Web UI for interactive use
- โ Java & Kotlin: Full support for both languages
- โ Multiple Frameworks: JUnit 5, Mockito, MockK, Kotest
- โ Spring Boot Ready: Special handling for Spring annotations and dependency injection
- โ Incremental Testing: Generate tests for specific files or entire projects
- โ Context-Aware: Understands your code structure and dependencies
๐ฆ Installation
pip install universal-tester
That's it! Both CLI and Web UI are included.
๐ฏ Quick Start
1. Configure Your LLM Provider
Create a .env file:
# Azure OpenAI
AZURE_OPENAI_API_KEY=your-api-key
AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com/
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4
LLM_PROVIDER=azure
# OR Google Gemini
GOOGLE_API_KEY=your-google-api-key
LLM_PROVIDER=google
# OR Ollama (local - FREE!)
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=llama2
LLM_PROVIDER=ollama
2. Generate Tests (CLI)
# Generate tests from a ZIP file
universal-tester --input /path/to/your-project.zip
# With custom output directory
universal-tester -i project.zip -o ./generated-tests
3. Or Use the Web UI
# Launch the web interface
universal-tester-ui
Then upload your ZIP file and click "Generate Tests"!
๐ก Usage Examples
CLI Examples
Basic test generation:
universal-tester --input myproject.zip
Kotlin with MockK:
universal-tester --input kotlin-app.zip --language kotlin --framework mockk
Use specific LLM provider:
universal-tester --input project.zip --llm-provider google
Verbose mode:
universal-tester --input project.zip --verbose
Web UI
- Start the UI:
universal-tester-ui - Open
http://localhost:8000in your browser - Upload your Java/Kotlin project (ZIP format)
- Click "Generate Tests"
- Download the generated test files
๐จ What Tests Look Like
Input: UserService.java
@Service
public class UserService {
@Autowired
private UserRepository userRepository;
public User findById(Long id) {
return userRepository.findById(id)
.orElseThrow(() -> new UserNotFoundException(id));
}
}
Generated: UserServiceTest.java
@ExtendWith(MockitoExtension.class)
class UserServiceTest {
@Mock
private UserRepository userRepository;
@InjectMocks
private UserService userService;
@Test
void findById_WhenUserExists_ReturnsUser() {
// Arrange
Long userId = 1L;
User expectedUser = new User(userId, "John Doe");
when(userRepository.findById(userId)).thenReturn(Optional.of(expectedUser));
// Act
User result = userService.findById(userId);
// Assert
assertNotNull(result);
assertEquals(expectedUser.getId(), result.getId());
assertEquals(expectedUser.getName(), result.getName());
verify(userRepository).findById(userId);
}
@Test
void findById_WhenUserNotFound_ThrowsException() {
// Arrange
Long userId = 999L;
when(userRepository.findById(userId)).thenReturn(Optional.empty());
// Act & Assert
assertThrows(UserNotFoundException.class, () -> userService.findById(userId));
verify(userRepository).findById(userId);
}
}
๐ง Configuration
Environment Variables
| Variable | Description | Required |
|---|---|---|
LLM_PROVIDER |
LLM provider: azure, google, or ollama |
โ Yes |
AZURE_OPENAI_API_KEY |
Azure OpenAI API key | If using Azure |
AZURE_OPENAI_ENDPOINT |
Azure endpoint URL | If using Azure |
AZURE_OPENAI_DEPLOYMENT_NAME |
Azure deployment name | If using Azure |
GOOGLE_API_KEY |
Google Gemini API key | If using Google |
OLLAMA_BASE_URL |
Ollama server URL | If using Ollama |
OLLAMA_MODEL |
Ollama model name | If using Ollama |
CLI Options
universal-tester [OPTIONS]
Options:
-i, --input PATH Input ZIP file path (required)
-o, --output PATH Output directory (default: ./generated_tests)
--llm-provider TEXT LLM provider override (azure/google/ollama)
--language TEXT Source language (java/kotlin)
--framework TEXT Test framework (junit/mockito/mockk/kotest)
-v, --verbose Enable verbose logging
--version Show version
--help Show help message
๐ Documentation
- Complete User Guide - Detailed documentation
- LLM Provider Setup - Configure Azure, Google, or Ollama
- Troubleshooting - Common issues and solutions
- FAQ - Frequently asked questions
๐ฏ Use Cases
For Developers
- Quickly create test scaffolding for new code
- Improve test coverage on legacy code
- Learn testing best practices from generated examples
- Speed up TDD workflow
For Teams
- Standardize test patterns across the codebase
- Onboard new team members with consistent test examples
- Reduce time spent writing boilerplate tests
- Focus on complex business logic testing
For CI/CD
- Integrate into build pipelines
- Generate tests automatically on code commits
- Maintain test coverage metrics
- Automate test creation for new features
๐ Why Universal Tester?
| Feature | Universal Tester | Manual Testing | Other Tools |
|---|---|---|---|
| Speed | โก Seconds | ๐ Hours | โก Fast |
| Quality | โ AI-powered | ๐ค Variable | โ ๏ธ Template-based |
| Customization | โ Flexible | โ Full control | โ Limited |
| LLM Choice | โ 3 providers | N/A | โ Usually locked |
| UI + CLI | โ Both | N/A | โ ๏ธ Usually one |
| Cost | ๐ฐ Free + LLM API | ๐ฐ๐ฐ Developer time | ๐ฐ๐ฐ๐ฐ Expensive |
๐ Privacy & Security
- Your code stays yours: Code is only sent to your chosen LLM provider
- Use Ollama for local processing: 100% offline operation available
- No data storage: We don't store or log your code
- Open source: Audit the code yourself (Apache 2.0 License)
๐ ๏ธ Requirements
- Python 3.8 or higher
- Access to an LLM provider:
- Azure OpenAI (paid)
- Google Gemini (paid, but has free tier)
- Ollama (free, runs locally)
๐ Project Structure
universal-tester/
โโโ universal_tester/
โ โโโ core.py # Main test generation logic
โ โโโ cli.py # Command-line interface
โ โโโ llm/
โ โ โโโ factory.py # Multi-LLM support
โ โ โโโ health_check.py # LLM health monitoring
โ โ โโโ java_validator.py # Code validation
โ โโโ detectors/
โ โ โโโ enhanced_import_detector.py # Java import detection
โ โ โโโ kotlin_import_detector.py # Kotlin import detection
โ โโโ prompts/
โ โ โโโ prompt_builder.py # LLM prompt construction
โ โ โโโ system_prompts.py # System-level prompts
โ โ โโโ ui_messages.py # UI messages
โ โโโ ui/
โ โโโ chainlit_ui.py # Web UI implementation
โ โโโ main.py # UI entry point
โโโ USER_GUIDE.md # Complete documentation
โโโ README.md # This file
๐ค Contributing
Contributions are welcome! Here's how:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
๐ License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Note on Commercial Use: While the software is open source under Apache 2.0, commercial use requires a separate license. Contact senthilthepro@hotmail.com for commercial licensing.
Patent Notice: The author reserves all patent rights related to the concepts and methods embodied in this software.
๐ Acknowledgments
๐ง Contact & Support
- Author: Senthil Kumar Thanapal
- Email: senthilthepro@hotmail.com
- PyPI Package: https://pypi.org/project/universal-tester/
๐ Quick Links
- PyPI Package
- User Guide
- Documentation included in package
Made with โค๏ธ for the testing community
Star โญ this repo if you find it useful!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file universal_tester-1.1.0.tar.gz.
File metadata
- Download URL: universal_tester-1.1.0.tar.gz
- Upload date:
- Size: 88.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b529e8fb3657a556c7adae4474febe2df1000ce81c434fb232524896a7e8d34a
|
|
| MD5 |
f5f5c37515e374cfbaf4f1d8e6c5c00c
|
|
| BLAKE2b-256 |
524eb774bd3cb9e6d700edfdb08b4028c5a086a7989a8b941259ffca66c0f84d
|
File details
Details for the file universal_tester-1.1.0-py3-none-any.whl.
File metadata
- Download URL: universal_tester-1.1.0-py3-none-any.whl
- Upload date:
- Size: 89.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
964a0774ada5c39da85cb07b5e4237a6788b32c8bf2ff929cec82583258da3ff
|
|
| MD5 |
aa78edcb03704291e5533b1e1f8bd84c
|
|
| BLAKE2b-256 |
b039be914da0d4afb66bcd9b9608edaece348e7ec8550a16dad08c81e64cae81
|