static fields as mocks
0 posts in topic
Flat View  Flat View

Posted By:   junit_maniac
Posted On:   Monday, February 25, 2008 05:54 PM

Hello everyone:

I am new to JUnit (and to java for that matter) and learning about Mock objects.

my question is on the reason as to why we use mocks, when there we can use a static instance of the object we need.

for example: INSTEAD OF DOING THIS--


List mockedList = mock(List.class);

why not use a static List instance in some class, like so


List statList = TestSetupClass.staticInstance; //a static List field

About | Sitemap | Contact