1

I'd like to debug my own vstest Adapter. I'm working on integrating of my own test framework/case into VS 2022. Currently, my adapter work on Test Explorer that I can see my dummy case on it. But, I don't know how to debug into the code of Adapter.

[DefaultExecutorUri("executor://XmlTestExecutor")]
    class TestDiscoverer : ITestDiscoverer
    {
        void ITestDiscoverer.DiscoverTests(IEnumerable<string> containers, IDiscoveryContext discoveryContext,
          IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
        {
            logger.SendMessage(TestMessageLevel.Informational, "Start discovery");

            var test = new TestCase(
                           "Assembly.Class.Method",
                           new Uri("discoverer://compatTestDiscoverer"),
                           @"D:\Code\HelloTestUnit\bin\Debug\net6.0\HelloTestUnit.dll");
            test.DisplayName = "Sample test case";
            test.CodeFilePath = @"D:\Code\HelloTestUnit\UnitTestA.cs";
            discoverySink.SendTestCase(test);
        }
    }

I have attached to vstest.console.exe process to debug, but vstest.console.exe seems like cannot use my adapter and my case cannot be found.

set VSTEST_RUNNER_DEBUG=1
set VSTEST_HOST_DEBUG=1
vstest.console.exe HelloTestUnit.dll /ResultsDirectory:d:\test /TestAdapterPath:VS.TestAdapter.dll
ever
  • 63
  • 6

1 Answers1

2

See https://github.com/microsoft/vstest-docs/blob/2e7becf3dae2e98b766772845e13c4038a5f6fbe/docs/diagnose.md for documentation on diagnosing VSTest issues.

The /TestAdapterPath switch should be set to the folder that contains your adapter, not the adapter DLL itself.

The code for your adapter will not be running in the vstest.console.exe process itself. It will run in testhost.exe, testhost.*.exe or possibly "dotnet exec testhost.dll", depending on the framework and architecture configuration. This process will be launched from VSTest.Console.exe.

Phil Deets
  • 86
  • 4