The development of ndroid can be said to be everywhere, not to mention exquisite apps, as long as you read some books, watch teaching videos, and study for two to three months, you can develop a few small projects at will, of course, you can only entertain yourself. of. Recently, I suddenly remembered about the automated testing of android, so I searched for relevant information on the Internet to learn, and finally decided to try robotium first.
robotium wiki:http://code.google.com/p/robotium/w/list
Here is an article about the introduction of robotium is very appropriate: robotium is a package of android's own class Instrumentation, which is convenient for testers to directly call the packaged interface, that is to say, in fact, we can use Instrumentation directly to perform automated testing, but robotium It can simplify our testing steps. We only need to call a robotium API and pass a few parameters, which means that we are calling a part of the Instrumentation to help us implement the test. Robotium is the second generation of rich!! Tall, handsome and rich!!
http://www.51testing.com/?uid-22381-action-viewspace-itemid-238847
requires attention:
1. Test project: For example: HelloWorldTest, Build Path needs to import robotium-solo.jar package
2.Eclipse: 3.7 version, you need to check the contents in Order and Export
- package com.luwenjie.helloworld.test;
- import android.test.ActivityInstrumentationTestCase2;
- import com.luwenjie.helloworld.HelloWorldActivity;
- import com.jayway.android.robotium.solo.Solo;
- publicclass HelloWorldTest extends ActivityInstrumentationTestCase2
- <HelloWorldActivity>{
- private Only only;
- //What is the app that needs to be tested?
- //Here we need to test the HelloWorldActivity application under the com.luwenjie.helloworld package
- public HelloWorldTest(){
- super("com.luwenjie.helloworld", HelloWorldActivity.class);
- }
-
- // Open the HelloWorld application
- publicvoid setUp() throws Exception{
- solo = new Solo(getInstrumentation(), getActivity());
- }
- // execute the test
- //searchText(String str): Verify that the string exists
- publicvoid testUI() throws Exception {
- boolean expected = true;
- boolean actual = solo.searchText("Hello") && solo.searchText("World");
- assertEquals("This and/or is are not found", expected, actual);
- }
- }
This article is from the " Xiao Maozi " blog, please keep this source http://xiaomaozi.blog.51cto.com/925779/908886