-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Currently the library starts tests on background threads by default. The behavior can be changed for an assembly by the following:
[assembly: VsTestSettings(UIThread = true)]I would propose running tests on the UI thread by default instead, using one of the following:
- Change the default for
UIThreadto true, or - Remove the
UIThreadproperty, and force the value was true
Overall, I believe this change better represents the requirements of code users are planning to execute as integration tests.
- Many VS APIs require are affinitized to the main thread, so they can be used directly in tests
- Integration tests typically cannot run concurrently due to state collisions within the IDE environment, so affinitizing them to the UI thread is not constraining
- While xunit in general is used for unit testing which does not require a main thread context, integration tests typically run in a more restricted environment. I would argue that it's acceptable to use a default which differs from other xunit frameworks because the host environment itself is "special".
This change would impact users in the following ways:
- The
IAsyncLifetimeinterface can be used to implement asynchronous initialization and cleanup code, since the UI thread will be blocked for the execution of constructors andDispose - Integration test methods should be asynchronous if they need to avoid blocking the UI thread
- Integration tests which need to run on the background thread can use
await TaskScheduler.Defaultto switch to a background thread
AArnott
Metadata
Metadata
Assignees
Labels
No labels