Add comprehensive test automation setup with GitHub Actions: - Create test.yml for running tests on main/develop branches - Add pr-test.yml for PR validation with test results comments - Add update-badges.yml for dynamic test status badge updates - Configure code coverage reporting with Codecov integration Documentation: - Add BADGE_SETUP.md with instructions for configuring test status badges - Add WORKFLOWS_GUIDE.md explaining CI/CD workflow setup - Update README.md with build and test status badges Test Framework: - Configure test project to use .NET 9.0 - Set up test coverage reporting with coverlet - Add integration tests with WireMock for API mocking - Add unit tests for configuration and HTTP client components - Document testing strategy in TestingStrategy.md Build: - Add Dockerfile.test for containerized testing - Update .gitignore for test artifacts - Configure test dependencies in VRCAuthProxy.Tests.csproj This change enables automated testing on PRs and branches, with visual status indicators and detailed test results in PR comments.
3.4 KiB
VRCAuthProxy Testing Strategy
This document outlines the comprehensive testing strategy for VRCAuthProxy, a proxy service for interacting with the VRChat API.
Overview
The testing strategy for VRCAuthProxy incorporates both unit tests and integration tests to ensure the reliability and robustness of the proxy service. The selected testing frameworks were chosen based on their active development status, community support, and compatibility with .NET 8.0.
Test Project Structure
The test project is organized into several directories:
Tests/
├── Unit/ # Unit tests
│ ├── ConfigTests.cs
│ └── HttpClientCookieContainerTests.cs
├── Integration/ # Integration tests
│ ├── VRChatAuthenticationTests.cs
│ └── ProxyIntegrationTests.cs
├── Helpers/ # Test helpers and fixtures
│ └── TestSetup.cs
└── VRCAuthProxy.Tests.csproj
Selected Testing Frameworks
The following frameworks were selected for their recent updates, robust feature sets, and compatibility with the VRCAuthProxy codebase:
- xUnit (v2.6.6) - Modern test framework for .NET with excellent parallel test execution.
- Moq (v4.20.70) - Popular mocking framework for isolating components in unit tests.
- FluentAssertions (v6.12.0) - More readable assertions with excellent error messages.
- WireMock.NET (v1.5.44) - HTTP mocking library for simulating the VRChat API.
- Microsoft.AspNetCore.Mvc.Testing (v8.0.3) - Framework for testing ASP.NET Core applications without mocking the HTTP pipeline.
- coverlet.collector (v6.0.0) - Code coverage tool for measuring test coverage.
Testing Approach
Unit Tests
Unit tests focus on testing individual components in isolation:
- Configuration loading and saving
- Cookie container handling
- Authentication flows
Integration Tests
Integration tests verify the interaction between components:
- End-to-end proxy request handling
- Authentication with the VRChat API
- Rate limiting and account rotation
- WebSocket proxying
Mocking Strategy
- The VRChat API is mocked using WireMock.NET to simulate various responses:
- Authentication success/failure
- TOTP verification
- Rate limiting
- Successful API responses
Running Tests
Execute the tests using the following command:
dotnet test
For code coverage reports:
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./lcov.info
Continuous Integration
The test suite is designed to be run in CI/CD pipelines. Include the following in your GitHub workflow:
- name: Test
run: dotnet test --no-restore --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./lcov.info
VRChat API Integration
The tests are designed to work with the VRChat API by:
- Mocking the API responses to simulate real-world scenarios
- Testing authentication flows including two-factor authentication
- Verifying that the proxy correctly handles rate limiting
- Ensuring proper WebSocket proxying
Areas for Future Improvement
- Load testing - Add tests to verify performance under high load
- Security testing - Add tests to verify that authentication tokens are properly handled
- Failure recovery testing - Enhance tests for VRChat API outages
- Cross-platform testing - Verify functionality across different operating systems