Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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.

How?

There is no usable guidance on the topic, except this: http://clear-lines.com/blog/post/unit-testing-vsto-projects.aspx

Thanks Dragan

share|improve this question

2 Answers 2

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 VB.net 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

 
discard

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.