JUnit???????????????????????JUnit3.8??
???????????? ???????[ 2015/8/26 10:31:00 ] ??????????????? Junit ???????
???????????
????????????unit testing?? ???????????е?С??????????м????????
?????????????????????????????????????????д???
?????????????????????ж???????н??????????????????????
????????????????????????????Test Case?? ??
????JUnit
????JUnit?????Java??????????????
????????????http://junit.org/
????Java????IDE??????Eclipse??????JUnit????????build path?????Library??????????汾???ɡ?
????JUnit??????????汾??JUnit 3.8??JUnit 4???????÷?????????÷???????
???????????????????ν???JUnit???????????????????
????http://www.cnblogs.com/mengdd/archive/2013/02/02/2890204.html
????????????????????????÷???
????1.??д??????????
?????????????????????JUnitTest???????д????????Calculator??
package com.mengdd.junit;
public class Calculator
{
public int add(int a?? int b)
{
return a + b;
}
public int subtract(int a?? int b)
{
return a - b;
}
public int multiply(int a?? int b)
{
return a * b;
}
public int divide(int a?? int b)
{
return a / b;
}
}
????2.???JUnit??
?????????????JUnit??????????
?????????????Properties->???Java Build Path->???Libraries->Add Library...
?????????????????JUnit?????Next???????JUnit 3????JUnit 4.
??????????????JUnit 3??
????3.??????????
?????????????????????
????1.???JUnit????????????????????????????
?????????????????????test??source folder?????????????????????????????????????????????????????
????????????????????е?????????class?????????????bin??????С?
????2.?????????????????????λ???????????棬??????????????????
???????????????в??????????????????????????λ???????????檔
????3.???????????????
??????????????????????????Test??
?????????????????????£?
????4.??????????д
?????????????????TestCase??
????TestCase??????:
????public abstract class TestCase
????extends Assert
????implements Test
????A test case defines the fixture to run multiple tests.
????To define a test case
????1) implement a subclass of TestCase
????2) define instance variables that store the state of the fixture
????3) initialize the fixture state by overriding setUp
????4) clean-up after a test by overriding tearDown.
????Each test runs in its own fixture so there can be no side effects among test runs.
???????????ο??????л????JUnit??????????????????????????
??????????????????Assert???μ?????????static void??????
??????
???·???
??????????????????
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