Posts

Showing posts from March, 2018

Java use different methods as mock in different environments

Many a time we feel that there should be a way by which we can invoke different functionality in a flow depending on the environment. How great it would be if in development environment one can just mock the database or any other external call and return dummy data for debugging purpose. However. , there are existing frameworks for testing like Mockito which let one simulate external objects by mocking return objects. Spring profile is also helpful to an extent by creating different profiles. All these existing frameworks are good for either testing or running code in any live environment, but for the desktop IDE based environment it is too much work to set them up. I wanted a simple approach that there should be some library which I can include and annotate my code to use a different method instead of real one in "test" and "development" environment. So I created one which is easy to use with no code pollution for myself. Since I find it good to use, I am sh