aspose file tools*
The moose likes Testing and the fly likes How to mock a complicate content Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How to mock a complicate content" Watch "How to mock a complicate content" New topic
Author

How to mock a complicate content

Wladimir Babitzki
Greenhorn

Joined: Apr 27, 2004
Posts: 19
What I need, it should be a possibility to go through a html page, sort links from it and look if the pages, referenced with the links, have also links. All the found links should be represented as a tree structure, whereby each link element should point to its children elements, that also can have links.

The implementation looks like:




That�s not clear for me, what is the best way to test the searchLinksAsTree? It�s simple with searchLinksAsList, there I can feed a mock content and check expected results, but to mock the content for the multi dimensional searchLinksAsTree is hard work.

I�ll appreciate any suggestion

Thank you
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
How about mocking that searchListsAsList() method while testing for searchLinksAsTree()?

I.e., instead of

try something like


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Wladimir Babitzki
Greenhorn

Joined: Apr 27, 2004
Posts: 19
Thanks! It�s really the simplest and nicest solution!
 
Consider Paul's rocket mass heater.
 
subject: How to mock a complicate content