Overview
Ryujinx uses comprehensive testing to ensure emulation accuracy and prevent regressions. Tests are written using NUnit and run automatically in CI.All test projects are in the
src/ directory with the Ryujinx.Tests* naming pattern.Test Project Structure
Ryujinx has several test projects:Running Tests
Run All Tests
- Command Line
- Visual Studio
- VS Code
- Rider
Run Specific Tests
Test Structure
Fromsrc/Ryujinx.Tests/Cpu/CpuTest.cs:12-14:
Key Components
1
TestFixture attribute
Marks a class as containing tests
2
SetUp method
Runs before each test to initialize state
3
TearDown method
Runs after each test to clean up
4
Test methods
Individual test cases
Writing CPU Tests
CPU tests validate ARM instruction emulation against Unicorn Engine.Example CPU Test
Fromsrc/Ryujinx.Tests/Cpu/CpuTestAlu.cs:
CPU Test Helpers
Fromsrc/Ryujinx.Tests/Cpu/CpuTest.cs:186-224:
SingleOpcode - Execute one instruction
SingleOpcode - Execute one instruction
CompareAgainstUnicorn - Validate results
CompareAgainstUnicorn - Validate results
SetWorkingMemory - Setup test memory
SetWorkingMemory - Setup test memory
Writing Memory Tests
Memory tests validate the memory management system.Example Memory Test
Fromsrc/Ryujinx.Tests.Memory/TrackingTests.cs:
Writing Audio/Renderer Tests
Fromsrc/Ryujinx.Tests/Audio/Renderer/:
Test Data
Value Sources
Generate test data usingValueSource:
Random Test Data
Fromsrc/Ryujinx.Tests/Cpu/CpuTest.cs:531-541:
Assertions
NUnit Assertions
Floating-Point Comparisons
CI Testing
From.github/workflows/build.yml:56-62:
CI Test Characteristics
Automatic Execution
Tests run on every PR and commit
Multi-Platform
Tests run on Windows, Linux, and macOS
Timeout Protection
10-minute timeout prevents hanging tests
Retry on Crash
Retry on code 139 (segfault) for flaky tests
Test Best Practices
DO
1
Test one thing per test
Each test should verify a single behavior
2
Use descriptive names
Test names should describe what is being tested
3
Arrange-Act-Assert pattern
4
Clean up resources
Use
TearDown or using statementsDON’T
Debugging Tests
Debug a Single Test
- Visual Studio
- VS Code
- Rider
- Command Line
Right-click test method → Debug Test(s)
Test Output
Code Coverage
Generate Coverage Report
Coverage Tools
- Coverlet: Cross-platform coverage
- Fine Code Coverage: VS extension
- dotCover: JetBrains coverage tool
Performance Testing
For micro-benchmarks, see the Performance guide.Simple Performance Test
Common Test Patterns
Parameterized Tests
Combinatorial Tests
Sequential Tests
Test Configuration
Fromsrc/Ryujinx.Tests/Ryujinx.Tests.csproj:21-24:
Skipping Tests
Next Steps
Debugging
Debug failing tests
Performance
Benchmark and optimize
PR Guide
Submit your tests