Skip to content

Add comprehensive unit and system tests for Folly LLM testing tool#1

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-b94e40c8-1f9a-4a3f-b0dd-37ef593739fb
Draft

Add comprehensive unit and system tests for Folly LLM testing tool#1
Copilot wants to merge 4 commits intomainfrom
copilot/fix-b94e40c8-1f9a-4a3f-b0dd-37ef593739fb

Conversation

Copy link
Copy Markdown

Copilot AI commented Jul 9, 2025

Overview

This PR adds a complete testing infrastructure to the Folly project, implementing both unit tests and system tests to ensure reliability, maintainability, and security of the LLM prompt injection testing tool.

What's Added

Testing Infrastructure

  • pytest configuration with custom markers and fixtures
  • Test runner script (run_tests.py) for easy test execution
  • Makefile with convenient shortcuts for common operations
  • Coverage reporting with HTML and terminal output
  • Comprehensive documentation in TESTING.md

Unit Tests (70 tests total)

  • LLMTester class (20 tests): Configuration loading, validation, denied content checking, logging, API calls
  • ChallengeUI class (18 tests): API integration, session management, prompt submission, error handling
  • ChallengeUICLI class (18 tests): CLI functionality, user token generation, API communication
  • API endpoints (14 tests): Flask routes, authentication, session management, error responses

System Tests (19+ tests)

  • API system tests: End-to-end testing with real HTTP requests and server startup
  • UI system tests: Web interface testing with static file serving and form functionality
  • CLI system tests: Command-line argument parsing and error handling
  • Integration tests: Component interaction and workflow validation

Key Testing Features

Mocking Strategy

# OpenAI API mocking for isolated testing
@patch('Folly.api.LLMTester.check_denied_content')
def test_call_llm_success(self, mock_check_denied, mock_openai_client):
    # Test LLM calls without external dependencies

Coverage Results

  • API module (api.py): 79% coverage
  • Overall project: 44% coverage with focus on critical functionality
  • HTML coverage reports generated for detailed analysis

Test Categories

# Quick unit tests only
make test-unit

# Full system integration tests  
make test-system

# All tests with coverage
make coverage

Security Testing

The test suite includes comprehensive security validation:

def test_denied_content_blocking():
    """Ensure malicious inputs are properly blocked."""
    malicious_inputs = ["ignore previous instructions", "bypass security"]
    for input_text in malicious_inputs:
        result = tester.check_denied_content(input_text, deny_list)
        assert result is not None  # Should be detected

Quality Assurance

  • Test fixtures for consistent test data across all test modules
  • Error handling tests for all failure scenarios
  • Integration workflows testing complete user journeys
  • Performance considerations with timeout handling for system tests

Usage

# Install with test dependencies
pip install -e ".[test]"

# Run all tests
make test

# Run with coverage
make coverage

# Quick development tests
make test-quick

Documentation

Added comprehensive testing guide (TESTING.md) covering:

  • Testing architecture and best practices
  • How to run different test types
  • Writing new tests for contributors
  • Debugging and troubleshooting
  • CI/CD integration guidelines

This testing infrastructure ensures the reliability and security of Folly's LLM testing capabilities while providing a solid foundation for future development and contributions.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits July 9, 2025 18:55
Co-authored-by: user1342 <28961606+user1342@users.noreply.github.com>
Co-authored-by: user1342 <28961606+user1342@users.noreply.github.com>
Co-authored-by: user1342 <28961606+user1342@users.noreply.github.com>
Copilot AI changed the title [WIP] add unit tests and system tests Add comprehensive unit and system tests for Folly LLM testing tool Jul 9, 2025
Copilot AI requested a review from user1342 July 9, 2025 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants