Files
pokemon-battle-engine/tests
cdemeyer-teachx aff99a507c code refactor
2025-08-20 13:02:04 +09:00
..
2025-08-14 10:19:03 +09:00
2025-08-20 13:02:04 +09:00
2025-08-15 12:38:44 +09:00
2025-08-14 10:19:03 +09:00

Tests Directory (tests/)

This directory contains all unit tests, integration tests, and test utilities for the Pokemon battle simulator.

Planned Structure

tests/
├── unit/                  # Unit tests for individual components
│   ├── core/              # Core system tests
│   │   ├── test_pokemon.cpp
│   │   ├── test_battle.cpp
│   │   ├── test_move.cpp
│   │   └── test_type.cpp
│   ├── data/              # Data loading tests
│   │   ├── test_loader.cpp
│   │   └── test_validator.cpp
│   ├── ai/                # AI system tests
│   │   ├── test_random_ai.cpp
│   │   └── test_minimax_ai.cpp
│   └── utils/             # Utility tests
│       ├── test_random.cpp
│       └── test_stats.cpp
├── integration/           # Integration tests
│   ├── test_full_battle.cpp
│   ├── test_ai_battles.cpp
│   └── test_data_loading.cpp
├── fixtures/              # Test data and fixtures
│   ├── sample_pokemon.json
│   ├── sample_moves.json
│   └── test_battles.json
├── helpers/               # Test helper utilities
│   ├── test_utils.h
│   ├── mock_pokemon.h
│   └── battle_builder.h
└── CMakeLists.txt         # Test build configuration

Testing Framework

  • Google Test (gtest): Primary testing framework - automatically downloaded via FetchContent
  • Google Mock (gmock): For mocking dependencies - included with Google Test
  • Test Coverage: Aim for >90% code coverage
  • Continuous Integration: Tests run on every commit
  • Version: Google Test v1.14.0

Running Tests

Build and Run

# Configure and build
cmake -B build -S .
cmake --build build

# Run all tests
cmake --build build --target test

# Run specific test types
cd build && ctest -L unit        # Unit tests only
cd build && ctest -L integration # Integration tests only

# Run with verbose output
cd build && ctest -V

Test Structure (Now Implemented)

tests/
├── unit/                  # Unit tests for individual components
│   ├── main.cpp           # Unit test entry point
│   ├── CMakeLists.txt     # Unit test build config
│   └── core/              # Core system tests
│       ├── CMakeLists.txt
│       └── test_example.cpp  # Example test (ready to run)
├── integration/           # Integration tests
│   ├── main.cpp           # Integration test entry point
│   └── CMakeLists.txt     # Integration test build config
├── fixtures/              # Test data and fixtures
├── helpers/               # Test helper utilities
└── CMakeLists.txt         # Main test build configuration

Test Categories

Unit Tests

  • Test individual classes and functions in isolation
  • Fast execution (< 1ms per test)
  • Mock external dependencies
  • Focus on edge cases and error conditions

Integration Tests

  • Test component interactions
  • Use real data files
  • Validate complete battle flows
  • Performance regression testing

Property-Based Testing

  • Random battle scenarios
  • Invariant checking (HP never negative, etc.)
  • Stress testing with large numbers of battles

Test Data

The fixtures/ directory contains minimal, controlled test data separate from the main game data, ensuring tests are:

  • Deterministic: Same results every run
  • Fast: Minimal data loading overhead
  • Isolated: Independent of main data changes