Robotium is a simple and powerful tool for android testing. It is simple because Robotium encapsulates two times based on the Android testing framework InstrumentationTestCase2 and simplifies some basic operations. Its documentation only has one Solo class, the configuration steps are fixed steps. It is powerful because it can test the source code in the source code for white-box testing. If no source code is available, only one application's apk can perform a black box test. In addition, you can capture every button, text control, image, and so on in the program. You can click the button by name or coordinate.
Now I will explain how to create a Robotium test project.
1. When source code is available
First, import the program source code to eclipse. Right-click eclipse and click "New" to go To the Android Project Creation page, as shown in Figure :( I updated it to android 4.1, the "Android Application Project" is the previous "Android Project ").
Then, select "Android Test Project". Note that it is not "Android Application Project", because you created a Test Project, not an Application Project, and the interface resources in the Project are unavailable, of course, if you mistakenly select "Android Application Project", you can still test it after configuration, but it will add a lot of useless resources.
Click "Next" and enter the name of your test project (for example, RobotiumTest ).
Click "Next". The following interface is displayed:
(Figure 3)
Note: This interface is a watershed. If you have the source code to be tested, click the "An existing Android project" option and select the source code to be tested, click "Next" to go To the Android api version selection page:
Select the desired api version and click "Finish.
2. When no source code is available:
This is the most common case. We usually test only one program apk, the source code is rarely seen, we do not need to have the source code, even without the program signature can also be carried out, of course, this will be detailed later.
As mentioned above, if no source code is available, create a program and select the "This Project" option in (3). Click "Next" to go To the android api selection interface, select the api version you want to use and click "Finish" to create the project.
As shown in, it is only an empty android test project, not an application project. There is no activity or layout file in it. Some people may ask, what is the relationship between this and robotium? I didn't see any shadows of robotium. That's right. Now this project has nothing to do with robotium. It is only limited by space. You cannot give it all in one sentence. For more information, see the next article.