With GLU.Ware you can configure your own ‘mocks’ and ‘stubs’ – a fundamental to delivering fully simulated and tested APIs. Mocking and/or stubbing is essential in scenarios where you are faced with external dependencies which may hinder the completion of your test/delivery cycle. The purpose of both is to eliminate testing all the dependencies of a class or function so your tests are more focused and simpler in what they are trying to prove.
A stub is an interface that simulates the actual object and returns pre-defined and expected Responses irrespective of input.
A mock is an interface with a bit more ‘intelligence’ in that you can configure you mock services to return results based on what you send.
- Speedy delivery
- Focused and reliable testing
- The ability o test components accurately in particular contexts
- Obtain feedback quickly from a manual or automated test
When to use a stubs & mocks?
If we are developing the back end of a minor application with a third-party to interact with an API, we can implement an interface that can disconnect us from the third-party library. Eventually, that interface will act as a stub and yield hard-coded values. Conclusively, we can use values in unit tests.