How do I get a Visual Studio test window to use my ITestContainerDiscoverer?

I am trying to write a test adapter for Visual Studio 2013 (I am running Premium with Update 1 and have a VS SDK, so I could reference all VS DLLs). Since it will work with raw content files and not dll / exe compiled, it seems I need to create one ITestContainerDiscoverer.

I found several public repositories on the Internet that seem to have implemented them; eg:

TypeScript , Json , Node , and many others

Nevertheless; my code seems the same (and the same links to VS DLLs), but it never works. I put File.Write, Console.WriteLine, Debuuger.Launch, and also added another VS instance to it. This is what my class looks like:

[Export(typeof(ITestContainerDiscoverer))]
public class MyTestContainerDiscoverer : ITestContainerDiscoverer
{
    [ImportingConstructor]
    public MyTestContainerDiscoverer([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider)
    {
        File.WriteAllText(@"M:\Coding\Applications\LuaTestAdapter\LuaTestAdapter\bin\Debug\Danny.txt", "TEST!");
        Console.WriteLine("IT RUNNING!");
        Debugger.Launch();
    }

    public Uri ExecutorUri
    {
        get { return TestExecutor.ExecutorUri; }
    }

    public IEnumerable<ITestContainer> TestContainers
    {
        get
        {
            return new[] {
                new TestContainer(this, @"M:\TestProject\Test.lua")
            };
        }
    }

    public event EventHandler TestContainersUpdated;
}

I create this in a DLL that ends with .TestAdapter.dll and manually copies it to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensionsand then starts VS. The TestAdapter loads VS correctly, because in the same project my TestDiscoverer (which currently includes the DLL as an extension for debugging) is output to the test console:

[FileExtension(".lua")]
[FileExtension(".dll")]
[DefaultExecutorUri(TestExecutor.ExecutorUriString)]
public class TestDiscoverer : ITestDiscoverer
{
    public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
    {
        logger.SendMessage(TestMessageLevel.Informational, "This one works!");
    }
}

Therefore, I assume that this should be something wrong with TestContainerDiscovered; but I just don’t see anything in the samples I found on the Internet, doing something differently: O (

+4
2

, ... Visual Studio "-", .

, "" (, DLL/EXE , , TestContainerDiscoverers) ( NUnit, xUnit .. NuGet DLL "" ), , "" "Asset" ( - MEF ITestContainerDiscoverer).

<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="LuaTestAdapter" Path="|LuaTestAdapter|" />
+6

, Visual Studio .exe .dll.

, (, .lua), :

  • ITestContainer
  • ITestContainerDiscoverer

:

  • ITestDiscoverer
  • ITestExecutor

, , :

cd Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow

vstest.console.exe /listdiscoverers /useVsixExtensions:True

- :

typescript testadapter

, . , , , , .

, , Microsoft, . , vsixmanifest ..

, ...

, -...

+3

Source: https://habr.com/ru/post/1525932/


All Articles