Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need end-to-end guidance on this topic.

Here is a scenario: I have a Word AddIn written in C#, in which I have some interop interaction with Excel. I need to unit-test that.


There is no usable guidance on the topic, except this:

Thanks Dragan

share|improve this question

The answer to almost all questions about unit testing is "decouple from dependencies".

Refactor your code to decouple the logic (which you want to test) from the interactions with with Excel.

Remember that unit tests should answer the question "does the code I am writing do what I intend it to do" and not "does my program work properly" - that's for integration tests.

share|improve this answer

I haven't done this type of testing, what I would recommend is looking into how you can write office macros that utilise the functions of your add-in to test it's functionality. You should be able to add vba command buttons to a spreadsheet or document or the word toolbar that runs your tests.

I am assuming that as you are testing and adding in VSTO, you have a good working knowledge of the excel and word APIs as that would be required.

share|improve this answer
I'm trying to unit test it using VS and C# – Dragan Panjkov Feb 5 '12 at 8:53
You should pronely use otherwise you will have lots of Type.missing calls. If you are going to call from VS, you should use the COM api to drive word and your add-in. – Bruce McLeod Feb 5 '12 at 21:11
Re. Type.missing : I use .NET 4.0, so luckily I don't have those in my code. – Dragan Panjkov Feb 6 '12 at 8:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.