??Eclipse?????JUnit4???е??????
???????????? ???????[ 2013/11/22 16:58:25 ] ????????
???????? ??????
????JAVA?е??????????????????????????д?Щ???????????????????????????????????????????????????????????????Bug????????Bug???? JUnit??????????????????????????????Bug?????磬????д??????????г????????????????????0????????????“??0??”????????????б??????Щ???в???????????£?
????@Test(expected = ArithmeticException.class)
????public void divideByZero() ...{
????calculator.divide(0);
????}
?????????????????????????????@Test?????expected????????????????????????????????JUnit?????????????????????????????????????
??????? Runner (??????)
?????????????????????????????????????JUnit?????????????????????????????——Runner????JUnit???к??? Runner?????????????????????????Runner???и???????????????????????????Runner????????????????????????????????????д?????????????????????????Runner??????????JUnit??????????Runner?????????????????????????????Runner???????????????仰??????????δ????????????????
????import org.junit.internal.runners.TestClassRunner;
????import org.junit.runner.RunWith;
????//???????????TestClassRunner?????????????????
????public class CalculatorTest ...{
????...
????}
????@RunWith(TestClassRunner.class)
????public class CalculatorTest ...{
????...
????}
???????????????????????????????Runner????????@RunWith???????????????????Runner???????????????????????????????@RunWith???????????????????????????κ????????????????????Runner???????????е????к??????????Runner?????á??????????????????Package??????????????????д????????????????????????????????Runner?????й????
?????塢 ??????????
???????????????????????????????????????????????????????????????????????磬??????????????????????????????????“????????????????????”??????????д?????????????д5???????????5??????????????????????????鷳?????顣?????????????????????????????“??????????????”????????????????????????0??????????????????£?
????import org.junit.AfterClass;
????import org.junit.Before;
????import org.junit.BeforeClass;
????import org.junit.Test;
????import static org.junit.Assert.*;
????public class AdvancedTest ...{
????private static Calculator calculator = new Calculator();
????@Before
????public void clearCalculator() ...{
????calculator.clear();
????}
????@Test
????public void square1() ...{
????calculator.square(2);
????assertEquals(4?? calculator.getResult());
????}
????@Test
????public void square2() ...{
????calculator.square(0);
????assertEquals(0?? calculator.getResult());
????}
????@Test
????public void square3() ...{
????calculator.square(-3);
????assertEquals(9?? calculator.getResult());
????}
????}
??????
???·???
??????????????????
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