Comprehensive Testing Guide for MTG Commander Online
This document serves as the central index for all testing documentation related to our networked MTG Commander implementation. It provides an overview of our testing strategy and links to detailed documentation for specific testing areas.
Core Principles
Our testing strategy for the online MTG Commander implementation is built on the following core principles:
- Comprehensive Coverage: Testing all aspects of the system, from individual components to full end-to-end gameplay
- Realism: Simulating real-world conditions, including varied network environments and player behaviors
- Automation: Maximizing the use of automated testing to enable frequent regression testing
- Game Rule Compliance: Ensuring the implementation adheres to all Commander format rules
- Security: Verifying that hidden information remains appropriately hidden
- Performance: Validating that the system functions well under various loads and conditions
Testing Documentation Structure
Document | Description |
---|---|
Core Testing Strategy | Outlines the fundamental approach to testing the networking implementation |
Advanced Testing Strategies | Covers specialized testing approaches for Commander-specific needs |
Integration Testing | Details testing at the boundary between networking and game engine |
Security Testing | Approaches for testing information hiding and anti-cheat mechanisms |
Testing Types
Unit Testing
Unit tests focus on individual components in isolation:
- Networking protocol components
- State synchronization mechanisms
- Game rule implementation
- Command processing
Integration Testing
Integration tests verify components work together correctly:
- Networking and game state management
- Client/server communication
- Action validation and execution
- Priority and turn handling
System Testing
System tests examine the complete system's functionality:
- Full game scenarios
- Multiple players
- Complete turn cycles
- Commander-specific rules
Network Simulation Testing
Tests under various network conditions:
- High latency
- Packet loss
- Jitter
- Bandwidth limitations
- Server/client disconnection and reconnection
Test Implementation Guidance
When implementing tests, follow these guidelines:
- Test Isolation: Each test should run independently without relying on state from other tests
- Determinism: Tests should produce consistent results when run multiple times with the same inputs
- Clear Assertions: Use descriptive assertion messages that explain what is being tested and why it failed
- Comprehensive Verification: Verify all relevant aspects of state after actions, not just one element
- Cleanup: Tests should clean up after themselves to avoid interfering with other tests
Test Data Management
Standard test fixtures are available for:
- Player configurations
- Deck compositions
- Board states
- Game scenarios
Use the TestDataRepository
to access these fixtures:
#![allow(unused)] fn main() { // Example of using test fixtures #[test] fn test_combat_interaction() { let mut app = setup_test_app(); // Load a predefined mid-game state with creatures let test_state = TestDataRepository::load_fixture("mid_game_combat_state"); setup_game_state(&mut app, &test_state); // Execute test // ... } }
Continuous Integration
Our CI pipeline automatically runs the following test suites:
- Unit Tests: On every push and pull request
- Integration Tests: On every push and pull request
- System Tests: On every push to main or develop branches
- Security Tests: Nightly on develop branch
- Network Simulation Tests: Nightly on develop branch
Test results are available in the CI dashboard, including:
- Test pass/fail status
- Performance benchmarks
- Coverage reports
- Network simulation metrics
Local Testing Workflow
To run tests locally:
# Run unit tests
cargo test networking::unit
# Run integration tests
cargo test networking::integration
# Run system tests
cargo test networking::system
# Run security tests
cargo test networking::security
# Run network simulation tests
cargo test networking::simulation
For more detailed output:
cargo test networking::integration -- --nocapture --test-threads=1
Additional Testing Resources
Contributing New Tests
When adding new tests:
- Identify the appropriate category for your test
- Follow the existing naming conventions
- Add detailed comments explaining the test purpose and expected behavior
- Update test documentation if adding new test categories
- Ensure tests run within a reasonable timeframe
By following this comprehensive testing strategy, we can ensure our networked MTG Commander implementation is robust, performant, and faithful to the rules of the game. Our testing suite provides confidence that the game will work correctly across a variety of real-world conditions and player interactions.
Networking Testing Documentation
This section provides comprehensive documentation on testing methodologies for our networked MTG Commander game engine.
Testing Overview
Testing networked applications presents unique challenges due to:
- Variable Network Conditions: Latency, packet loss, and disconnections
- State Synchronization: Ensuring all clients see the same game state
- Randomization Consistency: Maintaining deterministic behavior across network boundaries
- Security Concerns: Preventing cheating and unauthorized access
Our testing approach addresses these challenges through a multi-layered strategy, combining unit tests, integration tests, and end-to-end tests with specialized tools for network simulation.
Testing Categories
Unit Tests
Unit tests verify individual components and systems in isolation:
Integration Tests
Integration tests verify that multiple components work together correctly:
- Client-Server Integration
- Game State Synchronization
- RNG Integration Tests
- Replicon RNG Integration Tests
End-to-End Tests
End-to-end tests verify complete game scenarios from start to finish:
Performance Tests
Performance tests measure the efficiency and scalability of our networking code:
Security Tests
Security tests verify that our game is resistant to cheating and unauthorized access:
Test Implementation Guide
When implementing tests for our networked MTG Commander game, follow these guidelines:
- Test Each Layer: Test network communication, state synchronization, and game logic separately
- Simulate Real Conditions: Use network simulators to test under realistic conditions
- Automation: Automate as many tests as possible for continuous integration
- Determinism: Ensure tests are deterministic and repeatable
- RNG Testing: Pay special attention to randomized game actions
Testing Tools
Our testing infrastructure includes these specialized tools:
- Network Simulators: Tools to simulate various network conditions
- Test Harnesses: Specialized test environments for network testing
- RNG Test Utilities: Tools for verifying random number determinism
- Benchmarking Tools: Performance measurement utilities
Key Test Scenarios
Ensure these critical scenarios are thoroughly tested:
- Client Connection/Disconnection: Test proper handling of clients joining and leaving
- State Synchronization: Verify all clients see the same game state
- Randomized Actions: Test that shuffling, coin flips, etc. are deterministic
- Network Disruption: Test recovery after connection issues
- Latency Compensation: Test playability under various latency conditions
Testing RNG with Replicon
Our new approach using bevy_replicon for RNG state management requires specialized testing:
- Replicon RNG Testing Overview
- RNG State Serialization Tests
- Checkpoint Testing
- Network Disruption Recovery
- Card Shuffling Tests
Test Fixtures and Harnesses
We provide several test fixtures to simplify test implementation:
For more detailed information on specific testing areas, refer to the corresponding documentation links above.