Android Junit will verify that the button is getting started

I have a menu with some button, each of which triggers an action. I am writing a Junit test for this menu, and I cannot figure out how to verify that the button has loaded the correct activity. Still i

public void testButtons() { TouchUtils.clickView(this, buttonView); assertEquals(com.fgap.ontrack.newsFeed.class, getActivity()); } 

So far, I see that the program is loading the correct activity from the emulator, but the Junit test still does not work.

+7
source share
2 answers

If you know how to use de-bugger, you can try to see what the value of com.fgap.ontrack.newsFeed.class is and what the value of getActivity () is when it runs the test (you can use breakpoints or monitor variables to find out what their value is at any time). This can help you understand whether you are comparing the right things or comparing what you think you are comparing.

0
source

This is an old question, but if someone came across it.

To see if an action is triggered by clicking a button, you need to create an ActivityMonitor and set the activity class that you are checking to see if it is open.

  ActivityMonitor activityMonitor = getInstrumentation().addMonitor(activity.class.getName(), null, 

The full answer can be seen here: https://stackoverflow.com/a/318677/

0
source

All Articles