??????Junit????????
???????????? ???????[ 2015/6/2 10:04:04 ] ????????????????
?????????????????????д??????????????????????д??????????
?????????????????д?????????????????????????????в?????????????
????github???????? https://github.com/luhan420/jiedui/tree/master
????????????????http://www.cnblogs.com/tj1024/p/4490680.html
???????????
??????????????淶
??????????????Junit4???в????Eclipse??????Junit4??????
????1) ??????????
???????????DAO??service?????????????д??????????action????struts2.0??????????????ò????
????1. ??????????????????? ???? + Test????junit4????????????????????????
??????????????????????????????????
????2. ?????????src??е?test???????в??????????????????????????????
??????????????????
????3. ????????????????????????????????
????4. ???????????????????????????????????
????2) ???????????д
????1. ??????????test????????(testXXXX)??JUnit??????????????е?????
?????С???????????????????????????????????????????????????????????
????2. ????????У???????(assertXXX??fail??????????????JUnit???)??????
???????????ж?????????????????????????????????????????????????????????????????????
????3. ??????????????????????????????й?????????????????????????
?????????????????????????????????????????
????3) ????????????
????????????????????????????????????????????sql?????????????????????????????????????????????????????????????????????
????4) ????????
????????????????Entity model?????????????????????????????Entity???????????????????Entity??????set/get????????????y??е???????
????5) DAO??????
????????DAO???????д????????????DAO?????????????????в????????????????????д????????????????????п??????????????????????????????????????????????????????????
????6) Service??????
????Service????????????Service???????????????????????????????
????7) Struts??????????????
????????…
????????Eclipse??JUnit???÷?
???????????????JUnit???÷?????????÷?????????????????
???????????????????????Eclipse??JUnit???÷???
????????????????д??????????????????????д??????????
????1) ????Math??
????/**
????* @???????May 9??2015
????* @?????? */
????public class Math {
????public static int divide(int x??int y) { return x/y;
????}
????public static int multiple(int x??int y) { return x*y;
????}
????}
????2) ????????????
??????????????????????????????new->other??
????????main???????????????????????IDE???в???? setUp()???????????????????????????????????????? tearDown()?????????????????????????????????????
????setUpBeforeClass()????????????????????????????????????????????? tearDownAfterClass()????????????????????????????????????????? constructor()???????????????
??????????????
??????????????????????ɡ?
?????????????′???
????/**
????* @???????May 9?? 2015
????* @?????? */
????public class MathTest { @BeforeClass
????public static void setUpBeforeClass() throws Exception { }
????@AfterClass
????public static void tearDownAfterClass() throws Exception { }
????@Test
????public void testDivide() { fail("Not yet implemented"); }
????@Test
????public void testMultiple() { fail("Not yet implemented");
????}
????}
?????????
????@BeforeClass????????????????????????????????????????Σ?@AfterClass???????????????????????????????????Ρ???2??????????????????@Before??@After??????????????????????????????????????????????????????(????????????????????????????@Before??@After?????)
????@Test?????????????????????????????????????????С?
??????
???·???
??????????????????
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