Sunday, November 20, 2011

How to write unit test for getPopularItems()?

Hi,all

The Item can be viewed by visitor, the viewed counter will be saved in
database table(e.g. Items table). So getPopularItems() is to get the
most viewed items, according to the viewed counter of items.

The problem is:
What should I check in test case for getPopularItems()?

Since getPopularItems() get most viewed items according to the viewed
counter, If I use this method again to get most viewed items in
testGetPopularItems() and check if these two collections(popular
items) are equal, isn't it duplication?

I thought up one method:
Get the viewed count of most viewed(the first) item, then compare it
to the viewed count of several random items, check whether the former
viewed count is bigger or equal than latter one.

Is this method OK?

Any suggestion is appreciated.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate