|
|
пре 3 недеља | |
|---|---|---|
| .. | ||
| Application | пре 3 недеља | |
| Configuration | пре 3 недеља | |
| Drawing | пре 3 недеља | |
| Drivers | пре 3 недеља | |
| FileServices | пре 1 месец | |
| Input | пре 1 месец | |
| Resources | пре 1 месец | |
| Text | пре 3 недеља | |
| View | пре 3 недеља | |
| Views | пре 3 недеља | |
| AssemblyInfo.cs | пре 6 месеци | |
| LocalPackagesTests.cs | пре 1 месец | |
| README.md | пре 1 месец | |
| TestSetup.cs | пре 3 недеља | |
| UnitTests.Parallelizable.csproj | пре 3 недеља | |
| UnitTests.Parallelizable.csproj.DotSettings | пре 9 месеци | |
| runsettings.coverage.xml | пре 1 месец | |
| runsettings.xml | пре 1 месец | |
| xunit.runner.json | пре 9 месеци | |
This project contains unit tests that can run in parallel without interference. Tests here must not depend on global state or static Application infrastructure.
[SetupFakeDriver] without Application staticsView.Draw(), LayoutAndDraw() without Application staticsDriverAssert (when using [SetupFakeDriver])Application.TopView.BeginInit() / View.EndInit() for initialization[AutoInitShutdown] - requires Application.Init/Shutdown which creates global stateApplication.Driver (global singleton)Application.Init(), Application.Run/Run<T>(), or Application.Begin()ConfigurationManager global state (Enable/Load/Apply/Disable)ConfigurationManager including ThemeManager and SchemeManager - these rely on global stateSchemeManager.GetSchemes() or dictionary lookups like schemes["Base"] - requires module initializationView.Schemes - there can be weird interactions with xunit and dotnet module initialization such that tests run before module initialization sets up the Schemes arrayKey.Separator, CultureInfo.CurrentCulture, etc.Dialog.DefaultButtonAlignment) or any static fields/properties - these are shared across all parallel testsApplication.Top, Application.Driver, Application.MainLoop, or Application.NavigationUnitTests blindly use the above patterns when they don't actually need themUnitTests that don't actually need Application statics[AutoInitShutdown], Application.Begin(), etc. if not neededUnitTests.ParallelizableUnitTests to avoid duplicates// 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);
}
// Before (in UnitTests)
[Fact]
[SetupFakeDriver]
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);
}
// 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);
}
Tests in this project run in parallel automatically. To run them:
dotnet test Tests/UnitTestsParallelizable/UnitTests.Parallelizable.csproj