惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
Vercel News
Vercel News
Recent Announcements
Recent Announcements
B
Blog RSS Feed
Y
Y Combinator Blog
M
MIT News - Artificial intelligence
MongoDB | Blog
MongoDB | Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
雷峰网
雷峰网
D
Docker
Jina AI
Jina AI
IT之家
IT之家
人人都是产品经理
人人都是产品经理
L
LangChain Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
博客园 - 叶小钗
The GitHub Blog
The GitHub Blog
The Cloudflare Blog
A
About on SuperTechFans
Hugging Face - Blog
Hugging Face - Blog

博客园 - 随我畅翔

APP测试相关点归纳 APP自动化测试 android app 压力测试工具-monkey tool android测试开发环境搭建 通过CMD命令行创建和使用Android 模拟器 AVD android 内存泄露测试 NullPointerException检测 iOS Automated Tests with UIAutomation 命令方式重新签名apk Monkey log分析说明 iOS应用程序生命周期 RunTests.sh && RunIPhoneSecurityd.sh ios UI自动化测试 ios UnitTest 学习笔记1 如何通过Xcode 5中集成的XCTest框架进行简单的单元测试 curl命令使用大全 APP启动原理 Git和SVN的5个基本区别 IOS自动化测试之UIAutomation
编写Robotium测试程序
随我畅翔 · 2014-04-01 · via 博客园 - 随我畅翔

6.编写Robotium测试程序

1)导包 

//导入需要测试的工程  

import com.example.android.notepad.NotesList;

 //robotium提供的测试用类 

import com.jayway.android.robotium.solo.Solo; 

//测试工程要继承用来测试activity的父类 

import android.test.ActivityInstrumentationTestCase2;

2)泛型写需要测试的工程的入口activity名NotesList。 

public class NotePadTest extends  ActivityInstrumentationTestCase2<NotesList>{ „

 }

3)修改构造方法 

public NotePadTest(String name) { 

super("com.example.android.notepad", NotesList.class);}

4) 在测试方法前覆写父类的setUp()方法:  该方法用来初始化solo,绑定对应的Activity  

protected void setUp() throws Exception { 

solo = new Solo(getInstrumentation(), getActivity());}

5)在测试方法后覆写父类的tearDown()方法: 该方法用来清理资源垃圾,关闭activity。  

protected void tearDown() throws Exception { 
try {  
solo.finalize(); } catch (Throwable e) {  
e.printStackTrace(); 

getActivity().finish(); super.tearDown(); }