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.

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

  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.0.tar.gz (88.1 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.0-py3-none-any.whl (89.7 kB view details)

Uploaded Python 3

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

Hashes for universal_tester-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b529e8fb3657a556c7adae4474febe2df1000ce81c434fb232524896a7e8d34a
MD5 f5f5c37515e374cfbaf4f1d8e6c5c00c
BLAKE2b-256 524eb774bd3cb9e6d700edfdb08b4028c5a086a7989a8b941259ffca66c0f84d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for universal_tester-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 964a0774ada5c39da85cb07b5e4237a6788b32c8bf2ff929cec82583258da3ff
MD5 aa78edcb03704291e5533b1e1f8bd84c
BLAKE2b-256 b039be914da0d4afb66bcd9b9608edaece348e7ec8550a16dad08c81e64cae81

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