Xunit.StaFact

screenshot of Xunit.StaFact

Run your xunit-based tests on an STA thread with the WPF Dispatcher, a WinForms SynchronizationContext, or even a cross-platform generic UI thread emulation with a SynchronizationContext that keeps code running on a "main thread" for that test.

Overview

Xunit.StaFact is a powerful NuGet package designed to enhance the testing experience for applications that rely on Single Threaded Apartment (STA) threads, such as WPF and WinForms. With the potential to run tests on a main thread that closely resembles real-world UI scenarios, this package allows developers to ensure their applications perform seamlessly. The transition from xUnit v2 to v3 brings numerous enhancements, making it vital for developers to adapt their test structures accordingly.

This package supports an array of attributes tailored for different testing environments, empowering users to write effective parameterized tests with ease. Whether you're working within a Windows ecosystem or leveraging cross-platform capabilities, Xunit.StaFact caters to your testing needs to ensure robust applications.

Features

  • Versatile Test Attributes: Support for various attributes like [WpfFact], [WinFormsFact], [StaFact], and [UIFact] that can be adapted based on the required environment.
  • Cross-Platform Support: The [UIFact] and [UITheory] attributes work across all operating systems, ensuring that tests run smoothly regardless of the platform.
  • Parameterized Testing: Theory variants of the test attributes enable straightforward parameterization for comprehensive test coverage.
  • Enhanced SynchronizationContext: Custom SynchronizationContexts for different environments, allowing for effective testing scenarios that mimic main thread behavior.
  • Breaking Changes Management: Clear support for managing version differences between xUnit v2 and v3, making migration easier for developers.
  • Automated Retry Capability: The [UISettingsAttribute] offers the option to automatically retry unstable tests, increasing test reliability.
  • Windows-Only Functionality: Specific attributes designed for Windows, enabling STA threads in a controlled environment, while fallback mechanisms support cross-platform testing.
  • Detailed Documentation: Access to informative resources that help users get started quickly and efficiently with their testing strategies.