Add unit test integration


"unit test" could refer to "unittest.py", or could refer to other common testing frameworks. Add integrated support for running tests and displaying results.
Closed Jul 1, 2013 at 5:56 PM by RickWinter
Unit Test support is available in the 2.0 Beta release. We hope you enjoy it!


Sable wrote Nov 10, 2011 at 3:28 PM

We are really looking forward this feature in my company. We use Python to write unittests for a C++ application in the VS2010 environment.

Being able to launch a test case or a test suite from the environment would be a huge gain in productivity.

Is there any release date planned for this feature?
Is there something we could do to help get this functionality faster? sponsoring or something?

thanks in advance

dinov wrote Nov 10, 2011 at 6:07 PM

We're currently planning to do this work for 2.0. We're working on finishing up 1.1 right now and I expect we'll start work on 2.0 in the next month or two depending on incoming bugs against 1.1.

If you had someone who could get started on the feature right now we'd be happy to take contributions back.
I don't see a huge amount of documentation out there for this but http://blogs.msdn.com/b/terryclancy/archive/2009/11/18/visual-studio-2010-test-tools-partner-integration-opportunities.aspx seems like a good start. It may also be the case that we'll need to look to Dev11 for some additional extension points but hopefully we can do it all on top of Dev10.

dinov wrote Nov 11, 2011 at 2:29 AM

A little more info on what needs to be done here:
we need an ITestElement implementation, representing test cases http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.common.itestelement.aspx
  There's an abstract TestElement class that can be inherited from
we need an ITip interface http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.common.itip.aspx
  The Load method should return our test elements, and again, there's a base class we can inherit from
we need an ITestAdapter implementation http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.testadapter.itestadapter.aspx
We probably need a class derived from BaseTuip http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.vsip.basetuip.aspx
   This should be what wires us up to the UI
All of this should be put into a new PTVS package, opening up any APIs in the core package which are necessary for interacting w/ the project system. All of that's available on VS 2010 too, I was just couldn't find it this morning.

Sable wrote Nov 14, 2011 at 8:58 AM

Thanks for the feedback!
I will try to see if someone here can start working on that, or just wait a couple month until you start working on 2.0.

dinov wrote Jan 19, 2012 at 1:43 AM

Regarding my previous thoughts on how to do this - I started pursuing this and eventually hit a wall where our project types weren't being considered in the test code. Dev11 has some new testing APIs that we'll be able to integrate with. I've started looking into that but that means this feature won't be available until Dev11 is out.

Sable wrote Jan 19, 2012 at 1:40 PM

Ouch. We will eventually migrate to Dev11, but that may be in quite a long time.
Could it be possible to have at least some limited implementation?

What I am mostly looking for is some way to right click on a test method and then select "run test". Then this would just launch a python console with the right command line: python.exe path\test_script.py TestClass.test_method.

(and maybe the same when right clicking on a test class/suite, which would call python.exe path\test_script.py TestClass).

This would already be a huge improvement in our workflow with VS2010.

Zooba wrote May 31, 2013 at 11:29 PM

Checked in to 2.0 feature branch.