Forum Visual Studio

Visual Studio Extension: Can you ask Visual Studio for a list of available Unit Tests?

arthurdarthurd USMember ✭✭

I would like to write a custom extension for Visual Studio that would allow me to run a single UnitTest that my cursor is currently in with a keyboard shortcut.
Is there a way to ask for a list of Unit Tests that are currently loaded in the IDE (similar to what the "Unit Tests" pad shows) and then ask Visual Studio to run one of those tests? This would be done through the MonoDevelop.Addins package I assume.

Thanks in advance.

Best Answer


  • arthurdarthurd USMember ✭✭

    Thanks for that. The Extension's functionality is exactly what I was hoping to implement.
    I had no idea it was already built into the IDE!

    However, it would be nice if I could run the test my caret is currently in without having to use the mouse.
    I am attempting to apply the Key Binding named "Select test in tree" which I assume does exactly that.
    However, it doesn't seem to do anything when I execute the key combination.
    What is the purpose of this key binding please?

  • arthurdarthurd USMember ✭✭

    Also, on a side-note, the UnitTestService UnitTestService seems to be inaccessible in the MonoDevelop namespace.
    I am potentially doing something wrong when attempting to access it through my Add-In Extension code.

  • mattwardmattward GBMember Xamurai

    The UnitTestService class is public and in the MonoDevelop.UnitTesting namespace so if you have an addin reference to the UnitTesting addin then you should be able to use that class.

    It looks like the Select test in tree command tries to select the test from the list of tests shown in the Test Results window. So if the test is not visible then that is not going to find a test.

Sign In or Register to comment.