Testing tools for Visual Studio extensions

Shai Geva 26 Reputation points
2021-08-17T13:42:14.607+00:00

Hi,
I'm developing a new extension for Visual Studio and looking for how to test it (except for standard unit tests, of course).

I was hoping for a testing infrastructure that can run a light-weight UI-less Visual Studio instance, but couldn't find anything in the docs.
Does something like this exist? If not, are there any recommended testing practices to follow?

Thank you!

Community Center | Not monitored
0 comments No comments
{count} vote

Accepted answer
  1. Sergey Vlasov 266 Reputation points
    2021-08-18T03:49:58.123+00:00

    VsixTesting allows you to easily test your Visual Studio Extensions: https://github.com/josetr/VsixTesting

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Michael Taylor 60,326 Reputation points
    2021-08-17T13:55:27.217+00:00

    To be honest I think it completely depends upon your extension. Assuming you have unit tests that are mocking the various states that your extension relies on then the only other testing that would probably make sense is actually integration testing with VS itself. Everything else is just going to give you potentially false positives.

    As an example, your extension may request a service from VS. That call will likely work just fine in any test harness you have but fail in VS itself because: a) VS is calling your extension on a non-UI thread and the service isn't available there, or b) the service isn't available yet because the solution isn't loaded. These types of situations would be very hard to know about in advance and therefore test against. It is these types of situations that you would only know by running VS (and often only in certain circumstances). But then you'll detect an issue and add a unit test for it.

    So I believe the correct approach is to simply run integration tests using either the experimental instance of VS or perhaps a named instance that is installed on your test machines.

    I would also recommend that you ensure your extension is running the VS extension analyzer that will help detect these kinds of problems at build time as well but you might already be doing that.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.