Default behavior of the class is do nothing, if no stub. • spy() – creates a real object of the class. Default behavior of the class is the call real method, if no stub. 11
according to its equals() method. • isA() – checks that the argument is an instance of T, implying it is non-null. • any() – doesn’t do type checks with the given parameter, it is only there to avoid casting in your code. 19
when(mMockUserManager.login(eq(USERNAME), eq(PASSWORD))) .thenReturn(Observable.just(user)); // calls and verification } eq() checks that the argument equals to object according to its equals() method
is only there to avoid casting in your code. This might however change (type checks could be added) in a future major release. 22 @Test public void testGetInAppProductsSuccess() throws Exception { List<Product> product = getProductsFromFile(); when(mockPaymentApi.getProducts(eq("en"), any(BrandType.class))).thenReturn(product); // calls and verification }
only the observables you built, but also the resulting composition of the various operators you may want to apply to them. • Given a certain observable (or its mock), you will want to test how the rest of your application behaves while triggered by the subscription. 26