What is a stub and why is it used in testing? Solution Stub is a program that test the behaviour of the software component. It can be used in the place of the component in a program that has the same behaviour of the component it is replacing. It is used in the top down integration testing to check the behaviour of lower level module that are yet not integrated.They afre also used for the interaction with external system..