Tig d9899dcf1e merged 2 weeks ago
..
Application d9899dcf1e merged 2 weeks ago
Configuration b9f55a5a96 Fixes #4410, #4413, #4414, #4415 - `MessageBox` nullable, `Clipboard` refactor, fence for legacy/modern App, and makes internal classes thread safe. (#4411) 2 weeks ago
Drawing cd75a20c60 Fixes #4387. Runes should not be used on a cell, but rather should use a single grapheme rendering 1 or 2 columns (#4388) 3 weeks ago
Drivers b9f55a5a96 Fixes #4410, #4413, #4414, #4415 - `MessageBox` nullable, `Clipboard` refactor, fence for legacy/modern App, and makes internal classes thread safe. (#4411) 2 weeks ago
FileServices fdeaa8331b Fixes #4298 - Updates test namespaces (#4299) 1 month ago
Input b9f55a5a96 Fixes #4410, #4413, #4414, #4415 - `MessageBox` nullable, `Clipboard` refactor, fence for legacy/modern App, and makes internal classes thread safe. (#4411) 2 weeks ago
Resources d53fcd7485 Fixes #4374 - Nukes all (?) legacy Driver and Application stuff; revamps tests (#4376) 1 month ago
Text b9f55a5a96 Fixes #4410, #4413, #4414, #4415 - `MessageBox` nullable, `Clipboard` refactor, fence for legacy/modern App, and makes internal classes thread safe. (#4411) 2 weeks ago
View b9f55a5a96 Fixes #4410, #4413, #4414, #4415 - `MessageBox` nullable, `Clipboard` refactor, fence for legacy/modern App, and makes internal classes thread safe. (#4411) 2 weeks ago
Views d9899dcf1e merged 2 weeks ago
AssemblyInfo.cs cab22566ea Fixes #4107 - Revamps Terminal.Gui's `namespace` (#4109) 6 months ago
LocalPackagesTests.cs fdeaa8331b Fixes #4298 - Updates test namespaces (#4299) 1 month ago
README.md b9f55a5a96 Fixes #4410, #4413, #4414, #4415 - `MessageBox` nullable, `Clipboard` refactor, fence for legacy/modern App, and makes internal classes thread safe. (#4411) 2 weeks ago
TestDateAttribute.cs b9f55a5a96 Fixes #4410, #4413, #4414, #4415 - `MessageBox` nullable, `Clipboard` refactor, fence for legacy/modern App, and makes internal classes thread safe. (#4411) 2 weeks ago
TestSetup.cs b9f55a5a96 Fixes #4410, #4413, #4414, #4415 - `MessageBox` nullable, `Clipboard` refactor, fence for legacy/modern App, and makes internal classes thread safe. (#4411) 2 weeks ago
UnitTests.Parallelizable.csproj a6258ed398 Updates `IListDataSource.Render` to rename the `start` parameter to `viewportXOffset` (#4392) 3 weeks ago
UnitTests.Parallelizable.csproj.DotSettings b0f32811eb Fixes #3930 - Splits tests to `Tests/UnitTests`, `Tests/IntegrationTests`, `Tests/StressTests` (#3954) 9 months ago
runsettings.coverage.xml d53fcd7485 Fixes #4374 - Nukes all (?) legacy Driver and Application stuff; revamps tests (#4376) 1 month ago
runsettings.xml d53fcd7485 Fixes #4374 - Nukes all (?) legacy Driver and Application stuff; revamps tests (#4376) 1 month ago
xunit.runner.json b9f55a5a96 Fixes #4410, #4413, #4414, #4415 - `MessageBox` nullable, `Clipboard` refactor, fence for legacy/modern App, and makes internal classes thread safe. (#4411) 2 weeks ago

README.md

UnitTests.Parallelizable

This project contains unit tests that can run in parallel without interference. Tests here must not depend on global state or static Application infrastructure.

Migration Rules

Tests CAN be parallelized if they:

  • ✅ Test properties, constructors, and basic operations
  • ✅ Use [SetupFakeDriver] without Application statics
  • ✅ Call View.Draw(), LayoutAndDraw() without Application statics
  • ✅ Verify visual output with DriverAssert (when using [SetupFakeDriver])
  • ✅ Create View hierarchies without Application.Top
  • ✅ Test events and behavior without global state
  • ✅ Use View.BeginInit() / View.EndInit() for initialization

Tests CANNOT be parallelized if they:

  • ❌ Use [AutoInitShutdown] or [SetupFakeApplication]- requires Application.Init/Shutdown which creates global state
  • ❌ Set Application.Driver (global singleton)
  • ❌ Call Application.Init(), Application.Run/Run<T>(), or Application.Begin()
  • ❌ Enable ConfigurationManager (Enable/Load/Apply/Disable)
  • ❌ Access ConfigurationManager including ThemeManager and SchemeManager - these rely on global state
  • ❌ Modify static properties like Key.Separator, CultureInfo.CurrentCulture, etc.
  • ❌ Set static members on View subclasses (e.g., configuration properties like Dialog.DefaultButtonAlignment) or any static fields/properties - these are shared across all parallel tests
  • ❌ Are true integration tests that test multiple components working together

Important Notes

  • Many tests in UnitTests blindly use the above patterns when they don't actually need them
  • These tests CAN be rewritten to remove unnecessary dependencies and migrated here
  • Many tests APPEAR to be integration tests but are just poorly written and cover multiple surface areas - these can be split into focused unit tests
  • When in doubt, analyze if the test truly needs global state or can be refactored

How to Migrate Tests

  1. Identify tests in UnitTests that don't actually need Application statics
  2. Rewrite tests to remove [AutoInitShutdown] or [SetupFakeApplication], Application.Begin(), etc. if not needed
  3. Move the test to the equivalent file in UnitTests.Parallelizable
  4. Delete the old test from UnitTests to avoid duplicates
  5. Verify no duplicate test names exist (CI will check this)
  6. Test to ensure the migrated test passes

Example Migrations

Simple Property Test (no changes needed)

// Before (in UnitTests)
[Fact]
public void Constructor_Sets_Defaults ()
{
    var view = new Button ();
    Assert.Empty (view.Text);
}

// After (in UnitTests.Parallelizable) - just move it!
[Fact]
public void Constructor_Sets_Defaults ()
{
    var view = new Button ();
    Assert.Empty (view.Text);
}

Remove Unnecessary [SetupFakeApplication]

// Before (in UnitTests)
[Fact]
[SetupFakeApplication]
public void Event_Fires_When_Property_Changes ()
{
    var view = new Button ();
    var fired = false;
    view.TextChanged += (s, e) => fired = true;
    view.Text = "Hello";
    Assert.True (fired);
}

// After (in UnitTests.Parallelizable) - remove attribute!
[Fact]
public void Event_Fires_When_Property_Changes ()
{
    var view = new Button ();
    var fired = false;
    view.TextChanged += (s, e) => fired = true;
    view.Text = "Hello";
    Assert.True (fired);
}

Replace Application.Begin with View Initialization

// Before (in UnitTests)
[Fact]
[AutoInitShutdown]
public void Focus_Test ()
{
    var view = new Button ();
    var top = new Toplevel ();
    top.Add (view);
    Application.Begin (top);
    view.SetFocus ();
    Assert.True (view.HasFocus);
    top.Dispose ();
}

// After (in UnitTests.Parallelizable) - use BeginInit/EndInit!
[Fact]
public void Focus_Test ()
{
    var superView = new View ();
    var view = new Button ();
    superView.Add (view);
    superView.BeginInit ();
    superView.EndInit ();
    view.SetFocus ();
    Assert.True (view.HasFocus);
}

Running Tests

Tests in this project run in parallel automatically. To run them:

dotnet test Tests/UnitTestsParallelizable/UnitTests.Parallelizable.csproj

See Also