DEV Community

Discussion on: Quick Tip: Programming by Wishful Thinking

Collapse
 
aigarius profile image
Aigars Mahinovs

This combines very well with Test Driven Development and Mocks. At every step, before writing out a function, write 1-2 simple tests that call that function with a sample input and check its sample output. Once you have written the function plug the wished for functions with mocks that return expected results for the inputs. And presto - you already have test data for your next level of functions! When all is done, add a couple more calls to the top level function without any mocks and see how they all work in concert. Done!