Custom Test Adapter is not showing tests on Test E

2019-05-26 03:37发布

问题:

I am trying to implement a custom Test Adapter, all the files are bellow:

  • TSTestDiscoverer.cs
  • TSTestExecutor.cs
  • TSTestContainer.cs
  • TSTestContainerDiscoverer.cs
  • VsSolutionHelper.csfrom XMLTestDiscoverer source code

Using

vstest.console.exe /listdiscoverers /usevsixextensions:true

I confirmed that the extension is installed and it is listed on the test discoverers.

Running

vstest.console.exe file.ts

I confirmed that both TSTestDiscoverer and TSTestExecutor are working correctly.

Now I want to list the tests on Test Explorer, for that I guess I need ITestContainer and ITestContainerDiscoverer. I tried to implement both, but something is not working, the Test Explorer does not show any tests...

What did I do wrong? How can I find out what is not working?

回答1:

I forgot to add an attribute on the class that implements ITestContainerDiscoverer.

[Export(typeof(ITestContainerDiscoverer))]

Now it is working.



回答2:

I have found the blog post here http://blogs.msdn.com/b/mathew_aniyan/archive/2012/05/17/content-index-for-unit-test.aspx as very useful. It contains links to most of the MS stuff on unit testing, including the extension building. It also seems to be updated.

The post by the Chutzpah creator, Matthew Manela, is also very useful http://matthewmanela.com/blog/anatomy-of-the-chutzpah-test-adapter-for-vs-2012-rc/