¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

[TDD] Testing Searcher Object


 

How many ways are there for it to go right?? I can see a null response, a single return, multiple returns. Can it get duplicates? What other results are "happy" paths?

How many ways are there for it to go wrong? An invalid search? A backend that isn't working? An invalid input? what? What else?

Remember, you're testing the SEARCHER OBJECT not every possible search, or the system behind it.




On Mon, May 26, 2014 at 10:16 AM, Eb amaeze@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:


Hi -

We were having a conversation about testing a "searcher" object.? Basically, this object does a search based on the inputs passed into it.? Do tests have to be written for every permutation of inputs for the class to have been tested properly?

Thanks.

--
blog:
twitter: @eikonne





--
Tim Ottinger, Sr. Consultant, Industrial Logic
-------------------------------------




 

Thanks everyone for the feedback.? Exactly what we needed for our conversation.


On Tue, May 27, 2014 at 12:29 PM, Tim Ottinger tottinge@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:

?

How many ways are there for it to go right?? I can see a null response, a single return, multiple returns. Can it get duplicates? What other results are "happy" paths?

How many ways are there for it to go wrong? An invalid search? A backend that isn't working? An invalid input? what? What else?

Remember, you're testing the SEARCHER OBJECT not every possible search, or the system behind it.




On Mon, May 26, 2014 at 10:16 AM, Eb amaeze@... [testdrivendevelopment] <testdrivendevelopment@...> wrote:


Hi -

We were having a conversation about testing a "searcher" object.? Basically, this object does a search based on the inputs passed into it.? Do tests have to be written for every permutation of inputs for the class to have been tested properly?

Thanks.

--
blog:
twitter: @eikonne





--
Tim Ottinger, Sr. Consultant, Industrial Logic
-------------------------------------






--
blog:
twitter: @eikonne


 

All,

I'll 2nd what Tim said, with this addition:

Since this is a TDD forum (not a general testing forum) I'll assume you're asking how to determine what microtests to write in order to drive your code to completion.

One thing I recommend to people who are just trying out TDD for the first time is to trust your existing instincts, up to a point:? You already know what code needs writing to solve one of Tim's listed scenarios? STOP YOURSELF and ask "How would I test that?" What small step can you take independent of others, and how will you test (or justify) the existence of that code branch, subclass, method, or whatever?? When you pass in /this/, you should get /that/. Go ahead and figure out what code you are just itching to write, then work backwards from that point in the code, but don't write the solution code first.? First figure out how you would test it.

If the answer isn't simple, then you've bitten off too much behavior.? Try a smaller piece.

It may end up that a single object is responsible for a Search, but there's no restriction on your design that says it has to do all that work by itself.? Can you find some bit of the overall behavior which can be built independently?? nextResult.isUnique()? results.empty()? Can you then build upon that success, to create simple tests for broader behaviors?

Let me end by reassuring you:? If you can write the code, you can write the test.? First.

Enjoy!

Rob


Rob Myers
Principal Instructor & Coach, Agile Institute
Rob.Myers@...
Twitter: @agilecoach
http://www.agileInstitute.com/
Come learn TDD in Vegas! My promo code 14CBSCWRM61 gets you an additional $200 off Agile Development Conference West registration (you win before you've even reached the tables!) http://www.sqe.com/Registration/AgileDevWest/SelectConference.aspx?eventid=14CADPW&Type=Conf
Agile Institute¡¯s Essential Agile Engineering Practices now satisfies the 3-day technical requirement for the Scrum Alliance's Certified Scrum Developer curriculum.