??????????JUnit??????????????
???????????? ???????[ 2012/11/19 9:53:33 ] ????????
3.4??JUnit??????????
JUnit?????????
??http://download.sourceforge.net/junit/??????JUnit??????Junit????????????????????У?????C:Junit3.8.1????
???Junit.jar?????????????????C:Junit3.8.1Junit.jar????
?????????????Windows2000?????????????????????“????????á????????”??
????????????????“??”?????“????????”????“??????”??“????”?б???????“CLASS-PATH”?????????????Сд????????ù???????????????
???“CLASS-PATH”?????????????“C:Junit3.8.1Junti.jar”(?????????б????????????????????????β??????“??”)?????????????Junit????????????????????
????IDE??????????????????JUnit??????????lib?У??????ò????IDE?в???????? ??
3.5??JUnit?г?????????
Test???——???в?????????????
Test????????Composite??????????????????????TestCase??????????????TestSuite?????????????TestDecorator??????????
????public int countTestCases???????????????????β????ж????TestCase???????????????public void??run?? TestResult ????TestResult???????????????? run??????б??β????
TestCase??????——????????й??????
TestCase??Test???????????????????????????????У??乹????TestCase(string name)????????????????name????????????????????????TestCase????????????????????????????????????????????????????
TestCase???а?????setUp()??tearDown()??????setUp()???????г????????????????б???????????????????ε??ò??????е???????????????????setUp()??????tearDown()???????????????????????????????????????????????????
?????????д????????????????TestCase???????run????????????JUnit??ò????????????????run??????????????????TestResult??С?
Assert?????——???ж???????????
Assert????????????????????????????????????????????????????????Assert?????????AssertionFailedError????JUnit?????????????????Failes????????????????δ?????????????????????????String??????????ò??????????AssertionFailedError???????????????????????????????????
JUnit ????6????31????????????????????????????????????????????????????????
????assertEquals??Object expcted??Object actual)???????ж????equals()?????????????????????????????????????????????÷???????????????????б?????assertSame??Object expected??Object actual?????????ж??????Java?????“==”?????????????ж??????????????????????????Reference?????????÷???????????????????б???asserEquals(String message??String expected??String actual)?÷??????????????????????????????????????????????????в????????ComparisonFailure?????????????????????????????????????????
TestSuite???????——???????????
TestSuite??????????Test Cases??????????п????????????????????????TestSuit?????????Щ???????????????????????У???????????????????????
TestSuite???????Test??????????????????TestSuites??????????????Test????????????????
TestSuite?????????????6?????????????????в????
A ???????????????????Public??
B ????????????????TestCase??
C ????????????????????????е?? Public ??
D ?????????????????????????Void
E ?????????в????????????????????test
F ?????????в?????????κδ??????
n TestResult????????????????
TestResult??????????????????????????TestResult????????????????Run??????????TestResult?????TestCase??????????????
TestListener?????????????????????TestRunner????á?????listener???????????????????????????startTest(Test test)?????????endTest(Test test)????????????addError(Test test??Throwable t)?????????addFailure(Test test??AssertionFailedError t)
TestFailure????????“???”????????????????β?????й????г?????????????toString()????????“???”???????????
??????
???·???
??????????????????
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