Testing OnClickListener's post event completion job

18 views
Skip to first unread message

Amol Ghotankar

unread,
Jun 28, 2011, 8:07:53 AM6/28/11
to robol...@googlegroups.com
Hi,

I have a simple case where on activity I have a button.

Onclick of button, I do some background work like download a photo or something.

There are listeners for the onclick button like onPhotoDownloded() which are implemented in activity

How do I write test to these implementation of onPhotoDownloded()

I have a small sniplet here

@Test
    public void allEntered() throws Exception
    {
        EditText mobile =  (EditText) activity.findViewById(R.id.editText1);
        mobile.setText("123123123");
       
        EditText fbId =  (EditText) activity.findViewById(R.id.editText2);
        fbId.setText("amol.ghotankar");
       
        pressMeButton.performClick();
        String resultsText = results.getText().toString();
       
        assertEquals("Gettting Friends Details...\n Please wait", resultsText);
       
        /// Wait for sometime and when event is completed return the control to this method or any other method to continue the test for the success of method exection.
  
    }

Amol Ghotankar

unread,
Jun 28, 2011, 9:10:09 AM6/28/11
to robol...@googlegroups.com
Also on execution of this test I get a error

[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: There are test failures.

Please refer to D:\amol\test5\fbr\target\surefire-reports for the individual test results.

        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecyc
leExecutor.java:715)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(De
faultLifecycleExecutor.java:556)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycl
eExecutor.java:535)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailure
s(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(Default
LifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExe
cutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja
va:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.

Please refer to D:\amol\test5\fbr\target\surefire-reports for the individual test results.

        at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.
java:55)
        at org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugin.java:592
)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.j
ava:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecyc
leExecutor.java:694)
        ... 17 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 32 seconds
[INFO] Finished at: Tue Jun 28 18:39:19 IST 2011
[INFO] Final Memory: 28M/50M
[INFO] ------------------------------------------------------------------------
Reply all
Reply to author
Forward
0 new messages