Run Robotium test without starting activity

956 views
Skip to first unread message

lsim001

unread,
Apr 11, 2011, 6:09:36 AM4/11/11
to Robotium Developers
Hi guys,
Is it possible to run a Robotium test without starting an activity?

I currently have a test where I start off with a few manual steps
before I want to start my automated tests. However every time I run
my Robotium test it will start whatever activity I have configured it
with. I tried

solo = new Solo(getInstrumentation());

But this just closes the current activity and you end up back in the
Launcher. I also tried

solo = new Solo(getInstrumentation(), null);

and got the same behaviour.

According to the Android Test documentation getActivity() gets a
reference to the activity under test (SpinnerActivity). This call also
starts the activity if it is not already running. But it looks like
Robotium may be doing something a bit extra?

Thanks.

Renas Reda

unread,
Apr 11, 2011, 6:14:36 AM4/11/11
to Robotium Developers
Hi,

The way that Robotium works is that it will wait for an activity to be
started if you decide to create the Solo object with only
getInstrumentation(). Instead of using the activity that is given to
it with Solo(getInstrumentation(), getActivity()); it will wait until
it picks up an activity and then start to work from there. If you use
Robotium with ActivityInstrumentationTestCase2, getActivity() will
both return the activity and start it. So you would want to set up the
solo object before calling getActivity().

/Renas

Yahor Paulavets

unread,
Apr 11, 2011, 6:31:43 AM4/11/11
to robotium-...@googlegroups.com
Hello,

Could you please specify what exactly you want to do?

1. Do you want to use solo methods without providing solo class with activity?
2. Do you want to run test without solo and starting activity?
3. What do you mean 'Robotium test'?
- Robotium is a framework for automated testing, IMHO which is used to simplify UI testing..
IMHO UI testing = started Activity.

Best regards,
Yahor


--
You received this message because you are subscribed to the Google Groups "Robotium Developers" group.
To post to this group, send email to robotium-...@googlegroups.com.
To unsubscribe from this group, send email to robotium-develo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotium-developers?hl=en.


ricardo flora

unread,
Apr 11, 2011, 7:57:25 AM4/11/11
to robotium-...@googlegroups.com
Hi Renas
 
It's possible to call an activity inside the test , I have a application that when a I tap a button called other activity , how to do programing this ?
 
Thanks
 
Ricardo.

2011/4/11 Renas Reda <rena...@gmail.com>

Renas Reda

unread,
Apr 11, 2011, 8:05:39 AM4/11/11
to Robotium Developers
Hi,

Yes that is possible. One way of starting a new activity is (Below
example is from a class that extends Instrumentation, that can be
invoked from a test case):

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClassName(getTargetContext(),
"com.android.phone.Dialer");
Activity activity = startActivitySync(intent);

/Renas

On Apr 11, 1:57 pm, ricardo flora <ricardofl...@gmail.com> wrote:
> Hi Renas
>
> It's possible to call an activity inside the test , I have a application
> that when a I tap a button called other activity , how to do programing this
> ?
>
> Thanks
>
> Ricardo.
>
> 2011/4/11 Renas Reda <renasr...@gmail.com>

lsim001

unread,
Apr 13, 2011, 3:54:20 AM4/13/11
to Robotium Developers
1 & 2 - I don't know what I need to do technically but I know what I
want to do functionally.
3 - Robotium test = test that uses Robotium framework.

I agree that UI testing and more specifically black box UI testing
would almost certainly require starting an Activity. But that doesn't
mean that that activity has to be started via Robotium. You could
have started the activity manually or via another tool or test. In my
case I have already started my activity in another test.

On Apr 11, 11:31 am, Yahor Paulavets <ypaulav...@agilefusion.com>
wrote:

lsim001

unread,
Apr 13, 2011, 3:57:17 AM4/13/11
to Robotium Developers
Hi Renas,
But am I right in saying that after you have started the Dialer you
can't actually automate actions for it? I've read other posts saying
that you can't control activities that are not specified in your
manifest.

What I thought may be possible was to build a version of the Dialer
(using your example) from source and sign it with the debug key but
then how do you include it into your test project? Do you think this
would work?

Yahor Paulavets

unread,
Apr 13, 2011, 4:23:21 AM4/13/11
to robotium-...@googlegroups.com, lsim001
Hello,

You can not control activities, signed with different cert, no matter it is present in your manifest file or not.

If app signed with a same cert as your test - you can automate it.

Best regards,
Yahor

lsim001

unread,
Apr 13, 2011, 5:31:56 AM4/13/11
to Robotium Developers
Yes. That's why I was suggesting building the Dialer app with the
debug key. My app would also be built with the debug key so they have
the same key.

On Apr 13, 9:23 am, Yahor Paulavets <ypaulav...@agilefusion.com>
wrote:

Yahor Paulavets

unread,
Jun 14, 2011, 5:49:51 AM6/14/11
to robotium-...@googlegroups.com
Hi Renas,


"Yes that is possible. One way of starting a new activity is (Below
example is from a class that extends Instrumentation, that can be
invoked from a test case):

 Intent intent = new Intent(Intent.ACTION_MAIN);
       intent.setFlags(Intent.FLAG_
ACTIVITY_NEW_TASK);
       intent.setClassName(
getTargetContext(),
               "com.android.phone.Dialer");
       Activity activity = startActivitySync(intent);"


Could you please advise is there any way to get Activity reference inside the test, without starting activity in test's constructor and without firing an intent?

For instance, I want to fire test case from terminal to test device's after boot splash screen.
I need to find the way to get reference to the SplashScreen activity to interact with it.

Highly appreciate your work and help.

Best regards,
Yahor

Renas

unread,
Jun 15, 2011, 1:51:11 AM6/15/11
to robotium-...@googlegroups.com
Hi Yahor,

That is actually the only way that I have done it. So I am not sure how what you are asking for can be done. 

/Renas

Yahor Paulavets

unread,
Jun 15, 2011, 2:35:03 AM6/15/11
to robotium-...@googlegroups.com
Hello Renas,

Thanks, if I find any other way - I will update you :)

Best regards,
Yahor
Reply all
Reply to author
Forward
0 new messages