??Eclipse?????JUnit4???е??????
???????????? ???????[ 2013/11/22 16:58:25 ] ????????
????????????????????
????????????У????????????????????????????????????“???”???????????Щ??????????“???”???JDK5?????????????????????????????????????????Щ?????????@Before??@Test??@Ignore??????????Щ???????????“@”??????????Щ???????JUnit4?????????????????Щ???????????????
?????塢??д?????????????
?????????????????????????@Test??????????????????????????????????????????????????????????????????κ??????????????????? void????????????κβ????????Υ????Щ?漲???????????????????????????????дЩ??????????????????Щ????????磺
????@Test
????public voidtestAdd() ...{
????calculator.add(2);
????calculator.add(3);
????assertEquals(5?? calculator.getResult());
????}
????????????????“???”?????????????????????е??ü???add???????????0?????2?????3??????????????????5??????????????? 5???????add?????????????????????????assertEquals(5?? calculator.getResult());?????ж????????????????????????????????д???????????????????д?????????????????????????????д?????JUnit????????в??????????????????????
wordend ????????
Junit???spring????????
Junit???????????????????
JUnit?????????????????
???????? ????????Щ??δ???????
???????????д????????????滮???????Щ??????????????????????????????????÷?????δ??????????幦????????????????ζ????????????д?????????????????????????÷????????????д?????÷?????δ????????????????????“???”????????????????????????????????JUnit ?????????????????????????????????????????????@Ignore??????????????????“?Щ??????δ????????????β???”???????????????????????м????????????????????????????????????????????????@Ignore????????????????????????
??????? Fixture(????????“????????”)
????Fixture ???????“???Щ??α????????????”?????????????????????????????????Calculator?????????????0????????????????????????????0??;?????????????????????????????μ????????????????????????????!???????????????????????????????????κ????????????????б?????????????????????Calculator??????????“???”???????????????????????????????“???κ???????????????????е????”?????Fixture????????@Before???????????????????????
????@Before
????public void setUp() throws Exception ...{
????calculator.clear();
????}
?????????????@Test???????????????test?????????Fixture?????????“???κβ???????????????е???β????”??????Fixture?????@After????????????????????????????????
????JUnit4???Щ???????????????????Щ???????÷????????е?????и???????!
wordend ????????
Junit???spring????????
Junit???????????????????
JUnit?????????????????
??????????????£????????JUnit????????????????????????????????JUnit4???Щ????????
??????? ???Fixture
???????????????????????????Fixture??????????@Before??@After????????????????????????????1?????????????????????(???? 500??)???ж?д?????????????????????????в????????仰??????????????????????????????????????????????????????????????????????????????????@Before??@After???????β????????????????Ч???????????????????????????????в????????????????????в?????????????????????????β???????????JUnit????????????????????????????????@BeforeClass ?? @AfterClass????Fixture???????????????????????????????????????????Fixture????????????????????????????? @BeforeClass???????????в???????????????@AfterClass??????β??????????????????£???????????????????????????? @BeforeClass ?? @AfterClass??????÷?????????Public??Static???
???????? ????
??????????????????и????????????????????????????Bug????????????
????public voidsquareRoot(intn) ...{
????for(; ;) ; //Bug : ?????
????}
???????????????????????????????????????Ц?????????????Щ??????????????????????????п????????????????????????Щ????????????????????????????????????Щ????????趨????????????????????????????????????????????????????ú????????????????????????????????????ЩBug?????????????????????@Test????????????????????????£?
????@Test(timeout = 1000)
????public voidsquareRoot() ...{
????calculator.squareRoot(4);
????assertEquals(2?? calculator.getResult());
????}
????Timeout??????????????趨???????λ????????1000????1??
??????
???·???
??????????????????
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