jeudi 8 septembre 2016

Mock Constants inside an interface - Mockito getting "NoClassDefError"

I'm a newbee to unitTesting and Mockito I'm trying to unit Test the below code structure with Mockito

public interface AppConstants(){
   constants1;
   constants2;
}

public class Classname1(){ 
@Autowired    
private Classname2 classObj

public method1(){
file = classObj.getFile(AppConstants.constant1);
}
}

public class Classname2(){
public getFile(string){
}
}

Class unitTest(){
 @mock classname2 classobj
 @mock File file
@Test
public void testMethod1(){
   when(classobj.getFile(anyString())).thenReturn(file);
}
}

I'm getting error "NoClassDefFoundError" for AppConstants Please suggest me what I did wrong and a possible way around it .. Thanks

Aucun commentaire:

Enregistrer un commentaire