Could you insert the full error message you received?
The error message will also have a configuration of 2 Intents. If both of these intentions have the same configuration, this means that you call startActivity twice, that is, between the start of the test and the end of the test. Below is the answer for a specific case when you call the same Intent twice.
A challenge twice is a perfectly legitimate case. For instance,
Step 1 : press Button1 to launch the Gallery, and select the image and show it in ImageView1 (initially ImageView1 is GONE , but now it is VISIBLE ).
Step 2 : Click ImageView1 to start the gallery again.
Now, if you want to test βClicking on ImageView1 should launch theβ Gallery β, you cannot just click on ImageView1 , since it does not appear at the initial stage. You need to press Button1 first. If you do this, you need to launch the gallery twice .
Therefore, intended(hasComponent("mypackage.FundTransferActivity")); will not work. Instead use: intended(hasComponent("mypackage.FundTransferActivity"), times(2));
Henry source share