Test app logic and controls
Start with a behavior a user can notice: clicking Add changes the number, submitting an empty name shows an error, or returning to a page preserves its draft. Then choose the smallest test that can observe that behavior.
Pick the boundary
| Test | Use it for | What it does not establish |
|---|---|---|
| Ordinary unit test | Model rules, validation, math, state transitions | Layout or routed input |
| Component rendering test | One view's size and drawing | Native window behavior |
| Deterministic app test | Navigation, input routing, focus, controlled animation | Native IME, OS gestures, GPU presentation |
| Native end-to-end test | Real window/runtime integration | Every other platform |
A unit test that calls a button's callback directly checks the callback, not clicking. To test a click, render the view, find its target, and send down/up input through the app harness.
Run a small complete test
The counter test boots a tiny application, finds its button by ID, sends mouse input, and asserts the resulting label. Run that exact checked-in example from the repository root:
dotnet test Xui/Tests/Docs/Xui.Tests.Docs.csproj -c Release --filter FullyQualifiedName~CounterTest
The repository also separates larger suites:
dotnet test Xui/Core/Core.Tests/Xui.Core.Tests.csproj
dotnet test Xui/Tests/Component/Xui.Tests.Component.csproj
dotnet test Xui/Tests/Integration/Xui.Tests.Integration.csproj
Choose one focused suite while iterating. Full-solution builds can require mobile workloads unrelated to the change.
Assert state before pictures
A screenshot of the wrong page can look perfectly plausible. Assert the destination ID, edited text, selected item, or scroll offset before taking a snapshot. Use stable IDs to identify controls and derive coordinates from the current layout rather than hardcoding where a button used to be.
Keep native checks for behavior the software runtime cannot reproduce. Use visual regression tests to review appearance, and allocation measurements separately from functional tests.