Android automated testing - robotium (1) environment

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

 

 

 

  1. package com.luwenjie.helloworld.test; 
  2.  
  3. import android.test.ActivityInstrumentationTestCase2; 
  4. import com.luwenjie.helloworld.HelloWorldActivity; 
  5. import com.jayway.android.robotium.solo.Solo; 
  6.  
  7. publicclass HelloWorldTest extends ActivityInstrumentationTestCase2 
  8. <HelloWorldActivity>{ 
  9.  
  10.     private  Only only; 
  11.  
  12. //What is the app that needs to be tested?
  13. //Here we need to test the HelloWorldActivity application under the com.luwenjie.helloworld package
  14.  
  15.     public HelloWorldTest(){ 
  16.          super("com.luwenjie.helloworld", HelloWorldActivity.class); 
  17.     } 
  18.    
  19. // Open the HelloWorld application
  20.  
  21.     publicvoid setUp() throws Exception{  
  22.          solo = new Solo(getInstrumentation(), getActivity()); 
  23.     } 
  24.  
  25. // execute the test
  26. //searchText(String str): Verify that the string exists
  27.  
  28.     publicvoid testUI() throws Exception {  
  29.         boolean expected = true
  30.         boolean actual = solo.searchText("Hello") && solo.searchText("World"); 
  31.  
  32.         assertEquals("This and/or is are not found", expected, actual); 
  33.     } 

  34.  

 

 

This article is from the " Xiao Maozi " blog, please keep this source http://xiaomaozi.blog.51cto.com/925779/908886

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326425197&siteId=291194637