android cts and junit
2012-04-04 22:59
190 查看
Classes:from parent to child
1.
junit
?
Assert
复制代码
fail will throw error, other's function will call fail in the end.
2. TestCase
复制代码
TestCase has a method run(), which use java reflect to get the "Class" and "Method"
then call method.invoke() to start method.
3.InstrumentationTestCase
复制代码
1.
junit
packagejunit.framework;<br><br>publicinterfaceTest { publicabstractint countTestCases(); publicabstractvoid run(TestResult result); }
?
Assert
package junit.framework; public class Assert { ... assertTrue() assertFalse() fail() assertEquals() assertNotNull() assertNull() ... }
复制代码
fail will throw error, other's function will call fail in the end.
2. TestCase
package junit.framework; public abstract class TestCase extends Assert implements Test { protected void runTest() throws Throwable { assertNotNull(fName); Method runMethod= null; try { // use getMethod to get all public inherited // methods. getDeclaredMethods returns all // methods of this class but excludes the // inherited ones. runMethod= getClass().getMethod(fName, (Class[]) null); } catch (NoSuchMethodException e) { fail("Method \""+fName+"\" not found"); } try { runMethod.invoke(this, (Object[]) null); } .... } public String getName() { return fName; } public void setName(String name) { fName= name; } protected void setUp() throws Exception { } protected void tearDown() throws Exception { } ....
复制代码
TestCase has a method run(), which use java reflect to get the "Class" and "Method"
then call method.invoke() to start method.
3.InstrumentationTestCase
package android.test; public class InstrumentationTestCase extends TestCase { .... public final <T extends Activity> T launchActivity( String pkg, Class<T> activityCls, Bundle extras) { Intent intent = new Intent(Intent.ACTION_MAIN); if (extras != null) { intent.putExtras(extras); } return launchActivityWithIntent(pkg, activityCls, intent); } ... public void runTestOnUiThread(final Runnable r) throws Throwable { .... } ... protected void runTest() throws Throwable { ... } private void runMethod(Method runMethod, int tolerance) throws Throwable { runMethod(runMethod, tolerance, false); }
复制代码
相关文章推荐
- android cts and junit
- Junit and android test
- testBatchAndFlush(android.hardware.cts.SensorTest): WaitForFlush | sensor='PROXIMITY'
- [转载] Android bootloader/fastboot mode and recovery mode explained/Android boot process
- Android 学习笔记之AndBase框架学习(一) 实现多功能标题栏
- How to read Android crash log and stack trace
- Log.d and Log.v for Android
- Android中的Junit单元测试
- android安全和权限①----ShareUserId和文件访问(File Access)--Security and Permission
- Android AndBase框架内部封装实现进度框、Toast框、弹出框、确认框(二)
- Android兼容性测试框架(CTS)手册
- 【Android开发笔记】android studio 更新指定的 android sdk and java sdk (待补充)
- Linux Kernel and Android 休眠与唤醒
- MMS and SMS in android
- Android积累之《Wrong orientation? No orientation specified, and the default is horizontal, yet this la:》
- anddroid 新建工程时遇到:Failed to Resolved: com.android.support:appcompat-v7:15.+
- 第三章:Creating Applications and activities-(一)什么组成了一个Android应用
- Android Login and Registration with PHP, MySQL and SQLite
- Debug Android and Linux suspend and resume