Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing VSTO Applications?

I'm developing a Word 2007 VSTO application in VS2008. The part of the application that interacts with VSTO is difficult to test. VSTO objects behave differently than most class libraries. Their state and behaviors depend on how the user is interacting with Word, where they clicked, what's around the insertion point, etc. Mock objects could work in some scenarios, but they don't capture many of the subtleties of the VSTO objects.

Anyone have any experience with testing a VSTO based application they can share?

like image 201
Matthew Sposato Avatar asked May 18 '10 20:05

Matthew Sposato


People also ask

Is VSTO still supported?

VSTO add-in developer's guide - Office Add-ins | Microsoft Learn. This browser is no longer supported. Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

What can you do with VSTO?

You can use VSTO Add-ins to automate Microsoft Office applications, extend features of the application, and customize the user interface (UI) of the application.

How do I test an app in Visual Studio?

On the Visual Studio Test menu, select Test Explorer. The Test Explorer window opens. In Test Explorer, select the Run all icon. You must use Run all to discover tests in UWP projects.

How do I debug a VSTO add-in?

If you want to debug your VSTO Add-in by using a different version of Office (2013 or 2016), open the Project Designer, and in the Debug tab, choose the Start external program option button. Then, browse to the location of the appropriate Office application executable.


2 Answers

Use encapsulation to separate your logic from the API code. It is a very similar to how you unit test code that interacts with your database. Generally you can trust the API will work, like the database, but it is your logic that needs to be isolated so you can test it properly.

like image 132
JustEngland Avatar answered Nov 16 '22 01:11

JustEngland


I'm looking into this myself. A number of folks are pointing to Rhino Mocks http://hibernatingrhinos.com/open-source/rhino-mocks but I'd prefer use the real thing too. Have you tried varsha's msdn blog? http://blogs.msdn.com/b/varsha/archive/2010/08/17/writing-automated-test-cases-for-vsto-application.aspx?CommentPosted=true

like image 25
harvest316 Avatar answered Nov 16 '22 01:11

harvest316