Android Junit???????4????
???????????? ???????[ 2013/7/19 13:47:54 ] ????????
???????????????????????????Java ME????????????????Android?????JUnit?????????????????????????????????????????????????????????????????????Android?????Junit????????
?????????????????TestCase?????????androidTestCase????????getContext()?????????????????????????Android?????к??????????????Android api?????context??
????Java????
public class TestMath extends AndroidTestCase {
private int i1;
private int i2;
static final String LOG_TAG = "MathTest";
@Override
protected void setUp() throws Exception {
i1 = 2;
i2 = 3;
}
public void testAdd() {
assertTrue("testAdd failed"?? ((i1 + i2) == 5));
}
public void testDec() {
assertTrue("testDec failed"?? ((i2 - i1) == 1));
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
@Override
public void testAndroidTestCaseSetupProperly() {
super.testAndroidTestCaseSetupProperly();
//Log.d( LOG_TAG?? "testAndroidTestCaseSetupProperly" );
}
}
?????????????????TestSuit????????Junit??TestSuite???????????????????addTestSuite?????????????addTest?????????????
????Java????
public class ExampleSuite extends TestSuite {
public ExampleSuite() {
addTestSuite(TestMath.class);
}
}
??????
![](/images/ad-banner/ad-banner.png)
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11