rahul7386 / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

Unable to execute second test case #572

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I want to execute both test cases. If I execute them individually they all 
success, but if I run all the test case it runs one, executes the 
tearDown(solo.finishOpenedActivities) and it doesn't restart the activity to 
execute the other tests. 

On debugging in Logcat, I guess that setUp method launches the MainActivity 
successfully before running the first testMethod, but on being revisited before 
the start of second testMethod, the same activity does not get relaunched.

Code does not enter into second test case. 

This is code:-

package com.demo.test;
import com.demo.test.Utility;
import com.jayway.android.robotium.solo.Solo;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import android.widget.EditText;
import android.widget.Toast;

@SuppressWarnings("rawtypes")
public class StartdemoApp extends ActivityInstrumentationTestCase2 {

    private Solo solo = null;
    private static final String LAUNCHER_ACTIVITY_CLASS_NAME = "com.FBT.LoadActivity";
    private static Class LAUNCHER_ACTIVITY_CLASS;
    String debugstatus = "DEBUG_STATUS";
    static {
        try {
            LAUNCHER_ACTIVITY_CLASS = Class.forName(LAUNCHER_ACTIVITY_CLASS_NAME);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    @SuppressWarnings("unchecked")
    public StartdemoApp() {
        super(LAUNCHER_ACTIVITY_CLASS);
    }

    @Override

    protected void setUp() throws Exception {
        super.setUp();           
        solo = new Solo(getInstrumentation(),getActivity());       
    }

    public void testLoginActivity() throws InterruptedException {       
        solo.waitForActivity(solo.getCurrentActivity().toString());
        solo.clickOnButton("Log In");       
        solo.waitForActivity(solo.getCurrentActivity().toString());

        if(solo.searchText("Login Details")){
            Utility.loginCredentials(solo);           
            Utility.clickDone(solo);           
            solo.waitForText("Signing In..."); // It will wait for text to come
            solo.searchText("Signing In..."); // It'll search text
        }

        solo.waitForActivity(solo.getCurrentActivity().toString());   
        solo.clickOnScreen(240, 756, 1); // To click image button
        solo.sleep(1000);
        Log.i(debugstatus, "Done with testLoginActivity()");

    }

    public void testMyProfileActivity() throws InterruptedException{   
        solo.waitForActivity(solo.getCurrentActivity().toString());
        solo.clickOnButton("Log In");       
        solo.waitForActivity(solo.getCurrentActivity().toString());

        if(solo.searchText("Login Details")){
            Utility.loginCredentials(solo);           
            Utility.clickDone(solo);           
            solo.waitForText("Signing In..."); // It will wait for text to come
            solo.searchText("Signing In..."); // It'll search text
        }

        solo.waitForActivity(solo.getCurrentActivity().toString());   
        solo.clickOnScreen(308, 688, 1); // To click Profile button
        solo.waitForText("My Profile");
        solo.sleep(500);
        solo.clickOnScreen(435, 74, 1); // To click on 'Logout'
        Log.i(debugstatus, "Done with testMyProfileActivity()");

    }

    @Override
    public void tearDown() throws Exception {
        solo.finishOpenedActivities();
        //super.tearDown();
    }
}

What version of the product are you using? On what operating system?
Working with Android API Level-17 on Win 7

Please provide any additional information below.
I am using .apk file, no source code available. I can't share .apk file.

Please provide more information.

Original issue reported on code.google.com by Tlakh...@gmail.com on 15 Jan 2014 at 6:56

GoogleCodeExporter commented 9 years ago
Please ask this in our developer group:

https://groups.google.com/forum/#!forum/robotium-developers

Original comment by renasr...@gmail.com on 15 Jan 2014 at 11:56

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
throws InterruptedException to throws Exception

Original comment by touchdia...@gmail.com on 2 May 2014 at 10:13