Skip to content

Testing

Charlie Kindel edited this page Apr 26, 2021 · 8 revisions

Unit Tests & Code Coverage

Terminal.Gui uses the following technologies for unit tests and for tracking code coverage.

  • xUnit for unit tests
  • Fine Code Coverage within VS to visualize code coverage
  • simon-k/[email protected] for generating code coverage badge

Learning about Unit Testing

If you are new to automated unit tests, here are some good, easy to read resources:

Automated Unit Tests

Terminal.Gui uses xunit for automated unit tests run automatically with Github Actions.

Current code coverage (for the most recently release nuget package):

Code Coverage

Notes

  • Running tests in parallel is disabled because Application is a singleton. Do not change those settings.

Guidelines for Adding More Tests

  1. Do. Please. Add lots.
  2. Read and follow this: MIcrosoft's .NET Unit Testing Best Practices
  3. IMPORTANT: Remember Application is a static class (singleton). You must clean up after your tests by calling Application.Shutdown.

See the README.md in UnitTests/ for details on how xunit is configured.

Standard Regression Tests required before submitting a Pull Request

  • Every PR should include at least one update or addition to the existing Unit Tests. If you fixed a bug, figure out how to write a test that ensures it never regresses.

  • UICatalog is a great sample app for manual testing. When adding new functionality, fixing bugs, or changing things, please either add a new Scenario to UICatalog or update an existing Scenario to fully illustrate your work and provide a test-case.

  • Ensure a UI Catalog Scenario has been developed that specifically exercises the code involved in the PR. This Scenario should explicitly and intentionally exercise the following common functional areas:

    • Absolute Positioning using constructors that take absolute coordinates (Rect, x, y, etc...).

    • Computed Positioning using constructors that do not take coordinates. Test various forms of computed positioning (e.g. Pos.Percent, Pos.Y(view), etc...) and sizing (e.g. Dim.Fill, ...).

    • Use the All Views Scenario to test Computed Positioning

  • Test on both Windows and Linux.

  • Run through every Scenario in UI Catalog and look for regressions or broken behavior.

    • Resize terminal window to check for layout and clipping bugs.
    • Drag Windows with the mouse looking for layout or clipping bugs.
    • Use tab and shift-tab to ensure tab behavior has not broken.
  • Run demo.c and ensure it has not broken (however, recognizing it's not a great sample any more).

Please edit this wiki with other regression tests you think of.