Reputation: 31
Could you please any one tell me How to mock up Java Constructor ? I tried as below. But it doesn't work.
new MockUp<UserCompanyDivision>()
{
@Mock
public UserCompanyDivision(String com, String div)
{
}
};
Upvotes: 0
Views: 982
Reputation: 16380
Since constructors don't have names like methods do, JMockit uses the special name "$init" for the corresponding @Mock
methods. For example:
new MockUp<UserCompanyDivision>() {
@Mock // matches a constructor having the same parameters
void $init(String com, String div) {
// ...
}
};
Note that this is described in the API documentation for @Mock
.
Upvotes: 2