views:

85

answers:

2

When developing a plug-in to application, using the application API which doesn't run independently of the application, is unit-testing even a possibility? What are strategies to test a plug-in that is tightly integrated with an application?

+2  A: 

Abstract out the host API with interfaces, and test against a mock host.

The key is that your logic is tested with the characteristic data that the host might provide.

If you have a code example, I can probably give you a better answer.

Brian Genisio
+1  A: 

Most people miss the point of about mock objects. They aren't about testing, they're about interface discovery. Or as Michael Feather's put it a different way in a recent blurb: API Wrapping.

Don't code directly against the api. Instead create your own interfaces that abstract that api and then write tests for your code.

I've done this when writing plugins for Eclipse and the results were far better than I had expected ahead of time.

Jeffrey Fredrick