I think I have some unit testing-dagger missed.
I am trying to test a class which implements this Interface:
public interface GetAndroidOSVersionInteractor {
public String execute ();
}
The class is this one:
public class GetAndroidOSVersionInteractorImpl implements GetAndroidOSVersionInteractor {
@Inject
public GetAndroidOSVersionInteractorImpl (){
super();
}
@Override
public String execute() {
String version = "android: " + Build.VERSION.RELEASE + " device: " + Build.MANUFACTURER + Build.MODEL;
return(version);
}
}
Its inject module is this one:
@Module(library = true, complete = false)
public class InteractorsModule {
@Provides
GetAndroidOSVersionInteractor provideGetAndroidOSVersionInteractor(GetAndroidOSVersionInteractorImpl getAndroidOSVersionInteractorImpl) {
return getAndroidOSVersionInteractorImpl;
}
}
But when I execute this test, it always return a -1 NullPointerException:
@RunWith(MockitoJUnitRunner.class)
public class GetAndroidOSVersionInteractorTest extends TestCase {
GetAndroidOSVersionInteractor getAndroidOSVersionInteractor;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
@Test
public void executeTest(){
final String os = getAndroidOSVersionInteractor.execute();
assertNotNull(os);
}
}
What am I missing? Is it a problem with Dagger 1.2? Could you explain me why this doesn't work?
Thank you very much.