vrcauthproxy/Tests/TestingStrategy.md
MiscFrizzy 319f1071bf feat(ci): Add GitHub Actions workflows for test automation and status badges
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.
2025-04-07 06:30:31 -04:00

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:

  1. xUnit (v2.6.6) - Modern test framework for .NET with excellent parallel test execution.
  2. Moq (v4.20.70) - Popular mocking framework for isolating components in unit tests.
  3. FluentAssertions (v6.12.0) - More readable assertions with excellent error messages.
  4. WireMock.NET (v1.5.44) - HTTP mocking library for simulating the VRChat API.
  5. Microsoft.AspNetCore.Mvc.Testing (v8.0.3) - Framework for testing ASP.NET Core applications without mocking the HTTP pipeline.
  6. 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:

  1. Mocking the API responses to simulate real-world scenarios
  2. Testing authentication flows including two-factor authentication
  3. Verifying that the proxy correctly handles rate limiting
  4. Ensuring proper WebSocket proxying

Areas for Future Improvement

  1. Load testing - Add tests to verify performance under high load
  2. Security testing - Add tests to verify that authentication tokens are properly handled
  3. Failure recovery testing - Enhance tests for VRChat API outages
  4. Cross-platform testing - Verify functionality across different operating systems