An intelligent Django-based web application that automatically generates comprehensive test cases using AI (OpenAI GPT models). This system helps developers and QA teams quickly create detailed test cases based on natural language requirements and specifications.
- π€ AI-Powered Generation: Uses OpenAI GPT-4o-mini and GPT-3.5-turbo to generate test cases from natural language requirements
- π Excel Template Support: Supports both SPEC and API template generation
- π File Upload Processing: Processes Excel files with multiple sheets for batch test case generation
- π¬ Chat History Management: Saves and manages conversation history with persistent storage
- π Excel Export: Exports generated test cases to professionally formatted Excel files
- π§ Template Generation: Creates SPEC and API documentation templates
- π Modern UI: Clean, responsive interface built with TailwindCSS
- π³ Docker Ready: Complete containerization for easy deployment
- Backend: Django 5.1.3 with Python 3.11
- Database: MySQL 8.0
- Frontend: HTML5, TailwindCSS, Vanilla JavaScript
- AI Integration: OpenAI API (GPT-4o-mini, GPT-3.5-turbo)
- File Processing: openpyxl for Excel manipulation
- Deployment: Docker & Docker Compose
- Web Server: Nginx (production)
testcase-generator/
βββ π ai-docs/ # AI documentation and guidelines
βββ π src/ # Source code
β βββ π testcase_generator/ # Main Django project
β β βββ settings/ # Environment-specific settings
β β βββ urls.py, wsgi.py, asgi.py
β β βββ __init__.py
β βββ π chatbot/ # Main Django app
β β βββ models.py, views.py, urls.py
β β βββ forms.py, serializers.py, utils.py
β β βββ tests/ # App-specific tests
β β βββ templates/chatbot/ # App templates
β βββ π static/ # Static files (CSS, JS, images)
β βββ π templates/ # Global templates
β βββ π media/ # User uploads and generated files
β βββ manage.py
βββ π config/ # Configuration files
β βββ nginx/, docker/, scripts/
βββ π tests/ # Integration tests
βββ π scripts/ # Utility scripts
βββ π requirements/ # Dependency management
βββ π Makefile # Development commands
βββ π .gitignore # Git ignore rules
- Docker & Docker Compose
- Git
- OpenAI API Key
git clone https://github.com/Team-4-NTA/testcase-generator.git
cd testcase-generator# Copy environment template
cp env.example .env
# Edit .env file with your configuration
# Add your OpenAI API key and other settings# Build and start all services
make build
make up
# Or use docker-compose directly
docker-compose up -d- Web Interface: http://localhost:8888
- Admin Panel: http://localhost:8888/admin
- Create Virtual Environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install Dependencies
pip install -r requirements/development.txt- Environment Configuration
cp env.example .env
# Edit .env with your settings- Database Setup
cd src
python manage.py migrate
python manage.py createsuperuser- Start Development Server
python manage.py runserverThe project includes a Makefile with common development commands:
# Development
make dev # Start development environment
make build # Build Docker containers
make up # Start all services
make down # Stop all services
make logs # Show logs
# Database
make migrate # Run database migrations
make createsuperuser # Create Django superuser
make backup # Backup database
# Code Quality
make lint # Run linting
make format # Format code
make test # Run tests
make security # Security checks
# Utilities
make clean # Clean up containers
make status # Show container status- Enter a Screen Name (e.g., "Login Screen")
- Describe the Requirements in natural language
- Click Send to generate test cases
- Review and export the generated test cases to Excel
- Prepare an Excel file with SPEC or API specifications
- Click Upload and select your file
- The system will process multiple sheets and generate test cases
- Download the generated test case Excel file
- Select Template option
- Choose SPEC or API template type
- Enter screen name and requirements
- Download the generated template
- View all previous chat sessions in the sidebar
- Click on any session to load its details
- Delete old sessions as needed
# All tests
make test
# Specific test types
python manage.py test chatbot.tests # Unit tests
python manage.py test tests.integration # Integration tests
python manage.py test --settings=testcase_generator.settings.testing # With test settings# Install coverage tools
pip install coverage
# Run tests with coverage
coverage run --source='.' manage.py test
coverage report
coverage html # Generate HTML report- Environment Configuration
# Set production environment variables
export DJANGO_SETTINGS_MODULE=testcase_generator.settings.production- Docker Production
# Use production docker-compose
docker-compose -f docker-compose.prod.yml up -d- Manual Deployment
# Install production dependencies
pip install -r requirements/production.txt
# Collect static files
python manage.py collectstatic --noinput
# Run migrations
python manage.py migrate
# Start with Gunicorn
gunicorn testcase_generator.wsgi:applicationKey environment variables for production:
# Required
SECRET_KEY=your-secret-key
OPENAI_API_KEY=your-openai-api-key
DATABASE_NAME=your-db-name
DATABASE_USER=your-db-user
DATABASE_PASSWORD=your-db-password
DATABASE_HOST=your-db-host
# Optional
ALLOWED_HOSTS=your-domain.com,www.your-domain.com
DEBUG=False
SECURE_SSL_REDIRECT=True| Endpoint | Method | Description |
|---|---|---|
/ |
GET/POST | Main interface and test case generation |
/export-excel |
POST | Export test cases to Excel |
/upload-template |
POST | Upload and process Excel files |
/generate-template |
POST | Generate SPEC/API templates |
/get-history/ |
GET | Get all chat sessions |
/get-chat-list/<id> |
GET | Get chat details for a session |
/delete-history/<id>/ |
DELETE | Delete chat session |
// Generate test cases
fetch('/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken
},
body: JSON.stringify({
screen_name: 'Login Screen',
requirement: 'User login functionality with validation'
})
});
// Export to Excel
fetch('/export-excel', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken
},
body: JSON.stringify({
screenName: 'Login Screen',
testCase: testCasesData
})
});The project uses environment-specific settings:
base.py: Common settings shared across environmentsdevelopment.py: Development-specific settingsproduction.py: Production-specific settingstesting.py: Testing-specific settings
Supports multiple database backends:
- Development: SQLite (default) or MySQL
- Production: MySQL with connection pooling
- Testing: In-memory SQLite
- Default Model: GPT-4o-mini-2024-07-18
- Fallback Model: GPT-3.5-turbo
- Rate Limiting: Configurable retry logic
- Error Handling: Comprehensive error management
- CSRF protection on all forms
- Input validation and sanitization
- File upload restrictions
- SQL injection prevention
- XSS protection
- Secure session management
- HTTPS enforcement
- Security headers
- Content Security Policy
- Rate limiting
- Environment variable protection
- Structured logging with different levels
- File and console output
- Request/response logging
- Error tracking
- Database connectivity
- AI API availability
- File system access
- Memory usage
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
- Follow PEP 8 style guidelines
- Use type hints where appropriate
- Write comprehensive tests
- Document new features
- Update documentation
# Install pre-commit
pip install pre-commit
# Install hooks
pre-commit install
# Run on all files
pre-commit run --all-filesThis project is licensed under the MIT License - see the LICENSE file for details.
- Check the documentation
- Review API documentation
- Open an issue
Q: OpenAI API errors
A: Check your API key in the .env file and ensure you have sufficient credits.
Q: Database connection issues A: Verify your database configuration and ensure the database server is running.
Q: File upload problems A: Check file size limits and ensure the file is in the correct format (.xlsx).
Q: Static files not loading
A: Run python manage.py collectstatic and check your static files configuration.
- Complete project reorganization
- Environment-specific settings
- Enhanced testing infrastructure
- Production-ready configuration
- Improved documentation
- Better development workflow
- Initial release
- Basic test case generation
- Excel file processing
- Simple web interface
- OpenAI for providing the AI models
- Django community for the excellent framework
- Contributors and testers
Made with β€οΈ by Team 4 NTA