Hello, I'm actually having the following issue:
java.lang.NullPointerException: Attempt to invoke virtual method 'io.reactivex.observers.TestObserver io.reactivex.Completable.test()' on a null object reference
at repositorio.RepositorioProductoTest.insertarProductoTest(RepositorioProductoTest.java:48)
While testing a Completable in my code
@Test
public void insertarProductoTest(){
repo.agregarElemento(productoDummy)
.test()
.assertComplete();
verify(repo).darInstanciaDB().darDaoProducto().agregarProducto(argumentCaptor.capture());
assertThat(argumentCaptor.getValue().getNombre(), Matchers.is("producto"));
}
repo variable is being mocked with the @mocked anotattion
And if it is useful, here is the .agregarElemento(...) method
public Completable agregarElemento(Producto elemento) {
return Completable.fromAction(()-> darInstanciaDB().darDaoProducto().agregarProducto(elemento));
}
I'm following this as example
https://github.com/googlesamples/android-architecture-components/blob/master/BasicRxJavaSample/app/src/test/java/com/example/android/observability/UserViewModelTest.java
Hope you can help me.
Hello, I'm actually having the following issue:
While testing a Completable in my code
repo variable is being mocked with the @mocked anotattion
And if it is useful, here is the .agregarElemento(...) method
I'm following this as example
https://github.com/googlesamples/android-architecture-components/blob/master/BasicRxJavaSample/app/src/test/java/com/example/android/observability/UserViewModelTest.java
Hope you can help me.