I'm developing on Android but i'm new on unit Testing (JUnit and mockito).
I wrote a method which you can call and forget about it (fire&forget). I't doesn't matter to you (at all) if it's correct or not.
The method just call to Google Analytics to send some analytic, so it's not really important on the App.
I call on my code to myGoogleAnalyticSingleton.googleAnalytics_sendViewProduct(myProduct)
and i forget about anymore about this.
The method "googleAnalytics_sendViewProduct(MyProduct myProduct)" is something like:
public void googleAnalytics_sendViewProduct(MyProduct myProduct) {
final GA_Product gaProduct = new GA_Product(myProduct.getId(),
myProduct.getName(),
myProduct.(so on));
trackerAnalytics.send(gaProduct);
}
So the question is: How can i test that each method (View a product, add to Cart a product, remove from cart a product, etc...) sends metrics and sends the correct parameters?
public void test_gaViewProduct() {
assertEquals(gaProduct.getId, myTestIdonMyProductModel);
assertEquals(gaProduct.getName, myTestNameOnMyProductModel);
assertEquals .....
assertTrue(sendWasCalled());
}
I'm new on testing, so i'm not sure if maybe there is something wrong on my thoughts.
Thank you.