Barry
Barry

Reputation: 1665

Using Mockito in GWT project

I am new to using Mockito and I am running through an example test class written in our GWT project.

At some places ,in order to get a Mock we used Mockito.mock(SecurityDao.class) but in other places in the same test class we instantiated other classes using the "new" keyword.

I think that in order to mock a class i need to pass in the interface as the parameter to Mockito.mock ,and if my class does not implement an interface then i need to use the "new" keyword to instantiate the class.

Is this correct?When should i really use Mockito.mock??

Thanks

Upvotes: 0

Views: 571

Answers (1)

Jason Terk
Jason Terk

Reputation: 6025

Always use Mockito#mock() when creating an object other than that under test. Mockito can create mocks for interfaces and classes.

Upvotes: 2

Related Questions