Skip to main content

Test Types

PowerToys uses multiple types of testing to ensure quality:

Unit Tests

Finding Unit Tests

Unit test projects follow naming conventions:
Examples:
  • FancyZonesUnitTests
  • AdvancedPasteUnitTests
  • PowerLauncherUnitTests
Typical locations:
  • Same folder as the module: src/modules/<Module>/Tests/
  • Sibling folder: src/modules/<Module>/<Module>UnitTests/
  • Separate test directory: src/tests/<Module>UnitTests/

Running Unit Tests

Using Visual Studio Test Explorer

  1. Open Test Explorer:
    • Menu: Test > Test Explorer
    • Keyboard: Ctrl+E, T
  2. Build the test project first:
  3. Wait for exit code 0 (build success)
  4. Run tests in Test Explorer:
    • Click Run All to run all tests
    • Right-click specific test to run individually
    • Use search/filter to find specific tests
Do not use dotnet test in this repository. PowerToys uses MSBuild and Visual Studio Test platform. Use Test Explorer or vstest.console.exe instead.

Using vstest.console.exe

Run tests from command line:

Writing Unit Tests

C# Unit Tests

Create test class with MSTest:

C++ Unit Tests

Using Microsoft Native Unit Test Framework:

UI Tests

Prerequisites

  1. Install WinAppDriver v1.2.1:
    • Download from WinAppDriver releases
    • Install to default location: C:\Program Files (x86)\Windows Application Driver
  2. Enable Developer Mode:
    • Settings > Update & Security > For developers
    • Select “Developer mode”
  3. Close PowerToys before running UI tests

Running UI Tests

  1. Build PowerToys solution:
  2. Build UI test project:
  3. Open Test Explorer (Ctrl+E, T)
  4. Run UI tests from Test Explorer

UI Test Project Structure

Follow the naming convention:
Example: src/modules/Hosts/Tests/Hosts-UITests/

Project File Template

Writing UI Tests

Inherit from UITestBase class:

UI Test Scope Options

Window size options:
  • WindowSize.Small_Vertical
  • WindowSize.Large
  • WindowSize.Maximized

Common UI Test Patterns

Finding Elements

Interacting with Elements

Visual Assertions

UI Test Pipeline

UI tests run automatically in the build pipeline: Pipeline URL: https://microsoft.visualstudio.com/Dart/_build?definitionId=161438 Pipeline options:

Fuzz Tests

Fuzz testing identifies security vulnerabilities by providing random/malformed input.

When to Use Fuzz Tests

Required for modules that:
  • Handle file I/O (reading, writing, parsing files)
  • Process user input (text, commands, data)
  • Parse external data formats (JSON, XML, images, etc.)
  • Interface with external APIs or services

Fuzz Test Implementation

C# Fuzz Tests with SharpFuzz

  1. Add NuGet packages:
  2. Create fuzz target:

C++ Fuzz Tests with libFuzzer

Running Fuzz Tests Locally

OneFuzz Integration

PowerToys integrates with Microsoft’s OneFuzz service for continuous fuzzing:
  • Runs automatically in CI/CD pipeline
  • Generates crash reports for security team
  • Provides coverage metrics
  • See Fuzzing Testing docs

Test Requirements

When to Update Tests

Always update tests when:
  • Adding new functionality
  • Changing existing behavior
  • Fixing bugs
  • Refactoring code
Acceptable to skip tests when:
  • Comment-only changes
  • Documentation updates
  • String/resource changes (with justification)
  • Whitespace/formatting fixes

Test Coverage Expectations

  • New modules must have unit tests
  • UI-based modules should have UI tests
  • File/input handling modules must have fuzz tests
  • Bug fixes should include regression tests

Testing Discipline

Before Opening a PR

  1. Build succeeds with exit code 0
  2. All existing tests pass locally
  3. New tests added for new functionality
  4. Tests pass in Test Explorer
  5. Fuzz tests implemented if handling file I/O or user input

Test Checklist

  • Unit tests written for new code
  • UI tests written for UI changes (if applicable)
  • Fuzz tests written for file/input handling (if applicable)
  • All tests pass locally
  • Tests documented with clear names
  • Edge cases covered
  • Exception handling tested
  • Performance considered for test execution time

Special Testing Requirements

Multi-Monitor Testing

Utilities requiring multi-monitor testing:
  • FancyZones
  • Display Fuser
  • Mouse Jump
Test configurations:
  • 2+ monitors with different resolutions
  • Different DPI settings (100%, 125%, 150%, 200%)
  • Primary monitor on left/right
  • Vertical arrangements
  • Monitor disconnect/reconnect

Multi-Computer Testing

Mouse Without Borders:
  • Requires 2+ physical computers
  • Cannot be adequately tested with VMs
  • Test across different Windows versions

Elevation Testing

Test both scenarios:
  • PowerToys running as normal user
  • PowerToys running elevated (administrator)
Ensure graceful degradation when not elevated.

Debugging Test Failures

Test Explorer Debugging

  1. Right-click test in Test Explorer
  2. Select Debug Selected Tests
  3. Breakpoints will be hit during test execution

Test Output

View test output in Test Explorer:
  1. Select failed test
  2. Click “Open additional output for this result” link
  3. Review stack traces and error messages

UI Test Debugging

Next Steps

Building

Build PowerToys from source

Debugging

Debug PowerToys modules effectively

Coding Style

Follow PowerToys coding standards

Creating New Utility

Create a new PowerToys utility