This is quite interesting idea that I found in Robect C. Martins’ book Clean Code: A Handbook of Agile Software Craftsmanship. With this idea you should write unit tests for 3rd part components. At the beginning it can look strange. Why should you do that? We buy 3rd part components to save money and time – we figure out that it will be cheaper and faster than our development process. We also believe that this components should be tested and should not have any errors.

On the other hand we should consider other perspective. After buying new component we very often spend some time to learn how to use it. At the beginning we are testing behaviour of new component. In this phase we will probably create a new small application. And then after tests this application is forgotten or deleted. With this behaviour we are wasting  our work that have been invested to create this small application. Of course not whole time is wasted because we gained knowledge about this component. But maybe we could do something better…

Let’s consider an alternative path. Instead of creating new small test application we could create unit tests that will simulate how we will be using 3rd part component in our application. Of course not always such approach is possible – especially when this 3rd part component is set of UI controls. You should think what you will gain when you will be using proposed approach. First of all each time when new version of used component will be released you will be able to check very fast if this new version of component is compatible with our application and provide same features like previous one. You will need just to run prepared unit tests. Secondly, those unit test will be a great documentation presenting how we should use 3rd part component in our application. It can be shown to new developers.