Skip to main content

AI-powered automatic test case generation for Java and Kotlin projects with Web UI and CLI

Project description

Universal Tester - AI-Powered Test Generation

PyPI version Python 3.8+ License

Automatically generate high-quality JUnit tests for Java and Kotlin projects using AI - with complete code privacy using local LLMs.

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.

๐Ÿ”’ Unique Security Feature

๐Ÿ”’ Unique Security Feature

Your Code Never Leaves Your Machine!

Unlike other AI testing tools that send your code to cloud services, Universal Tester supports Ollama - a runtime platform that lets you run powerful open-source LLMs (Llama, Mistral, CodeLlama, etc.) entirely on your own computer.

Why This Matters:

  • โœ… Complete Privacy: Your proprietary source code stays on your machine
  • โœ… 100% Offline: No internet required for test generation
  • โœ… Enterprise-Safe: Complies with strict corporate security policies
  • โœ… Zero Trust Architecture: No cloud providers can access your code
  • โœ… FREE: No API costs - unlimited test generation at no charge
  • โœ… Compliance-Ready: Meets requirements for regulated industries (healthcare, finance, government)

You Have Options: While Ollama provides maximum security through local LLM execution, you can also use Azure OpenAI or Google Gemini if your team prefers cloud-based models.

  • โœ… 100% Offline Operation with Ollama
  • โœ… No Cloud Uploads - Your code stays on your machine
  • โœ… Enterprise-Safe - Perfect for proprietary and sensitive codebases
  • โœ… FREE - No API costs with local models
  • โœ… Your Choice - Also supports Azure OpenAI and Google Gemini if preferred

๐Ÿš€ Features

  • โœ… ๐Ÿ” Local LLM Support (Ollama): Run any open-source LLM locally - your code never leaves your machine
  • โœ… Multi-LLM Support: Azure OpenAI, Google Gemini, or Ollama (run LLMs locally/offline)
  • โœ… 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
  • โœ… No Vendor Lock-in: Switch between LLM providers anytime

๐Ÿ“ฆ Installation

Prerequisites

  • Python 3.8+ (Tested and certified on Python 3.13.5)
    • โš ๏ธ Important: Requires Python 3.8 or higher to avoid compatibility issues
    • โœ… Certified on: Python 3.13.5
    • ๐Ÿ“‹ Compatible with: Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13+ (based on dependencies)
  • pip (Python package manager)
  • LLM API access (Azure OpenAI, Google Gemini, or Ollama)

Recommended: Use Virtual Environment

We strongly recommend using a virtual environment to avoid dependency conflicts:

# Create virtual environment
python -m venv universal-tester-env

# Activate on Windows
universal-tester-env\Scripts\activate

# Activate on Linux/Mac
source universal-tester-env/bin/activate

# Install universal-tester
pip install universal-tester

Install from PyPI

pip install universal-tester

That's it! Both CLI and Web UI are included.

Verify Installation

universal-tester --version

๐ŸŽฏ Quick Start

1. Configure Your LLM Provider

Copy .env.example to .env and configure:

# Ollama (FREE - Recommended for local development)
LLM_PROVIDER=ollama
OLLAMA_HOST=http://localhost:11434
OLLAMA_MODEL=llama3.1:8b

# OR Azure OpenAI
LLM_PROVIDER=azure_openai
AZURE_OPENAI_API_KEY=your-api-key
AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com/
AZURE_OPENAI_DEPLOYMENT=gpt-4

# OR Google Gemini
LLM_PROVIDER=google
GOOGLE_API_KEY=your-google-api-key
GOOGLE_MODEL=gemini-2.0-flash:generateContent

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

  1. Start the UI: universal-tester-ui
  2. Open http://localhost:8000 in your browser
  3. Upload your Java/Kotlin project (ZIP format)
  4. Click "Generate Tests"
  5. 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


๐ŸŽฏ 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:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. 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

  • Built with LangChain
  • UI powered by Chainlit
  • Inspired by the need for better automated testing tools

๐Ÿ“ง Contact & Support


๐Ÿš€ Quick Links


Made with โค๏ธ for the testing community

Star โญ this repo if you find it useful!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

universal_tester-1.1.1.tar.gz (93.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

universal_tester-1.1.1-py3-none-any.whl (91.8 kB view details)

Uploaded Python 3

File details

Details for the file universal_tester-1.1.1.tar.gz.

File metadata

  • Download URL: universal_tester-1.1.1.tar.gz
  • Upload date:
  • Size: 93.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for universal_tester-1.1.1.tar.gz
Algorithm Hash digest
SHA256 8e68c9a7b13e6cc20a8e8395a07db1940abdaec4d2c297565d5976d8813c16d0
MD5 8cb4ff9efe61f6796eb043c9d2f649eb
BLAKE2b-256 5149ead498efd15d7078a9f95b637dc8530492211e7245821058d802b483c365

See more details on using hashes here.

File details

Details for the file universal_tester-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for universal_tester-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d293822acbe4c78d8974b31e59c9a9192413bd5770a52d20b6210dda5b971549
MD5 90903cfccb260083941efde71a9735b1
BLAKE2b-256 201fac6f0ed433be14915c76d6b36b90ee5390d9dc574bccc42244763c6f846d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page