JUnit?????????t??????
???????????? ???????[ 2014/12/3 14:39:46 ] ?????????????????? Junit ??????
????1????Junit???????
????????????????????????????
????A??Junit??÷??????1
????1????Junit????????????
?????????? Java ????—coolJUnit???????coolJUnit ??????? -> ???“Java Build Path”????? -> ???“Add Library…”??? -> ???????“Add Library”?????????? JUnit???????????????汾 Junit 4 ????“Finish”???????????? JUnit ?????????????????
????2??????????????????
?????????????????????????????????е?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? coolJUnit ???????????????? testsrc???????????????????????С?
????3??????????????
?????????SampleCaculator?????????????????????????????????????
public class SampleCalculator {
//?????????????
public int add(int augend?? int addend){
return augend + addend;
}
//?????????????
public int subtration(int minuend?? int subtrahend){
return minuend - subtrahend;
}
}
????4??д??????????
???????SampleCalculator???????????????????????SampleCalculator.java?????????new>?Junit Test Case?????4????Source foler???testsrc???????next?????????????????????add??subtration?????????????finish??ɡ?
????Junit????????????SampleCalculatorTest????????е???????£???
????????assertEquals????????????????????????????????
????assertEquals( [Sting message]?? expected?? actual )
????expected?????????????????????????actual?????????????????????message???????????????????????????????????????????????????
???????????????????????????Java?????????float????double???????????????????????????????
????assertEquals([Sting message]?? expected?? actual?? tolerance)
????????????μ??α???ο??????????????????????????淶??д??
????1. ????????????????? org.junit.Test ???Ρ?
????2. ?????????????? public void ???Σ????????????κβ?????
????5???????н??
????????????????????????????????? Run As JUnit 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