通过AndroidTestCase来进行android 单元测试 part I
在以前的博客中介绍过了如何用intrumentation进行android单元测试,其实还有一种方法同样可以,那就是利用AndroidTestCase来做单元测试,intrumentationTestCase和AndroidTestCase都是Junit.framwork.TestCase的子类,二者代表不用的方向。
package com.ut.prac; import android.test.AndroidTestCase;import android.util.Log; public class MathTest extends AndroidTestCase { protected int i1; protected int i2; static final String LOG_TAG = "MathTest"; public void setUp() { i1 = 2; i2 = 3; } public void testAdd() { Log.d( LOG_TAG, "testAdd" ); assertTrue( LOG_TAG+"1", ( ( i1 + i2 ) == 5 ) ); } public void testAndroidTestCaseSetupProperly() { super.testAndroidTestCaseSetupProperly(); Log.d( LOG_TAG, "testAndroidTestCaseSetupProperly" ); }}?
2.? 定义一个test suite类。<!--[endif]-->
package com.ut.prac;import junit.framework.TestSuite;public class ExampleSuite extends TestSuite { public ExampleSuite() { addTestSuite( MathTest.class ); }}?
?