Skip to content

Fix discovery and running of tests in Visual Studio Test Explorer - #2

Open
dmalovric wants to merge 1 commit into
FastEndpoints:mainfrom
dmalovric:main
Open

Fix discovery and running of tests in Visual Studio Test Explorer#2
dmalovric wants to merge 1 commit into
FastEndpoints:mainfrom
dmalovric:main

Conversation

@dmalovric

Copy link
Copy Markdown

Made some changes to the integrated example so that test discovery works for both CLI and Test Explorer in Visual Studio:

  • Removed <OutputType>Exe</OutputType> as it is technically not necessary (but can be reintroduced if preferred)
  • Set <DisableTestingPlatformServerCapability>true</DisableTestingPlatformServerCapability> to address known issues with XUnit and VS Test Explorer
  • Added reference to Microsoft.NET.Test.Sdk as it's needed for Visual Studio Test Explorer
  • Added reference to xunit.runner.visualstudio as it's needed for Visual Studio Test Explorer
  • Created a small TestDiscoveryHandler that switches between:
    ConsoleRunner.Run(args);
    and
    TestPlatformTestFramework.RunAsync(args, SelfRegisteredExtensions.AddSelfRegisteredExtensions);
  • Change Program.cs to call TestDicoveryHandler.IsTestRun and run the appropriate test runner if this is a test run:
if (TestDiscoveryHandler.IsTestRun(args, out var testRunner))
  return await testRunner();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant