Skip to main content

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

Run Specific Tests

Test Structure

From src/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

From src/Ryujinx.Tests/Cpu/CpuTestAlu.cs:

CPU Test Helpers

From src/Ryujinx.Tests/Cpu/CpuTest.cs:186-224:

Writing Memory Tests

Memory tests validate the memory management system.

Example Memory Test

From src/Ryujinx.Tests.Memory/TrackingTests.cs:

Writing Audio/Renderer Tests

From src/Ryujinx.Tests/Audio/Renderer/:

Test Data

Value Sources

Generate test data using ValueSource:

Random Test Data

From src/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 statements

DON’T

  • Don’t test implementation details, test behavior
  • Don’t make tests depend on each other
  • Don’t use random data without a seed (makes failures unreproducible)
  • Don’t ignore failing tests - fix them or remove them

Debugging Tests

Debug a Single Test

Right-click test method → Debug Test(s)

Test Output

Code Coverage

Generate Coverage Report

Coverage Tools

Performance Testing

For micro-benchmarks, see the Performance guide.

Simple Performance Test

Common Test Patterns

Parameterized Tests

Combinatorial Tests

Sequential Tests

Test Configuration

From src/Ryujinx.Tests/Ryujinx.Tests.csproj:21-24:

Skipping Tests

Next Steps

Debugging

Debug failing tests

Performance

Benchmark and optimize

PR Guide

Submit your tests