How to test this?

Saloni Kaur
Apr 9, 2021

Ever had one of those encounters as a Software Developer where you are just like “How do I test this?” It seems so complicated but the solution turns out so simple!

So how do we unit test the above?

There is of course a way to test it, this is how I tested it initially:

But this is TOO COMPLICATED! (literally pulled some hair out!)

A colleague of mine had the idea “just separate into a new file and just test that”

Now the above is easy to test. And so is GetBooksQueryCallback!!

Now this is much easier to test!

Just wanted to put this out there since at least I forget these simple things from time to time..

Hope this helps!

Happy Coding!

--

--