I am trying to retrospectively unit test an application that is fairly complex but utilises MVC. I know retrospectively applying unit tests isn't ideal but I still believe it's possible by refactoring existing code. A majority of the time it is not possible to unit test one unit, without relying on other units i.e. a view relies on a model.
What is the best way to unit test in this case? Is it better to utilise the real model or create a mock model?
The problem with utilising a real model in my situation is that the model relies on other response classes that get data from XML so there's a chain of reliance. This model has a lot of data so it would be much easier to use this but maybe I'm missing the point.
I have provided a UML of the application for brevity.
**Edit ****
Ok so if I am correct, is it best practice to create mock data inside a mock class? for example I have the mock class "MockPlaylistPanelModel" that creates data required for the View class "PlaylistPanel" to run without errors:
class MockPlaylistPanelModel extends Mock implements IPlaylistPanelModel
{
/**
* Return all playlist items
* @public
*/
public function get mainPlaylistItems():Vector.<PlaylistData>
{
var playData:Vector.<PlaylistData> = new Vector.<PlaylistData>;
var playlistResp:PlaylistData = new PlaylistData(0, "", "", 0, 0, 0, 0);
playData.push(playlistResp);
return playData;
}
}