JUnit?? - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

JUnit??

Description:

Title: PowerPoint Presentation Last modified by: MG0632076 Created Date: 1/1/1601 12:00:00 AM Document presentation format: Other titles – PowerPoint PPT presentation

Number of Views:89
Avg rating:3.0/5.0
Slides: 18
Provided by: educ5460
Category:
Tags: junit | netbeans

less

Transcript and Presenter's Notes

Title: JUnit??


1
JUnit??
2
JUnit??
  • JUnit?? Erich Gamma ? Kent Beck
    ???????????(Regression Testing Framework),?Java???
    ??????????
  • ?????????????

3
??JUnit
  • Java?JUnit????????http//junit.org
  • ????junit.zip?????????
  • ??????
  • VariableCLASSPATH
  • Variable Value .Install Path/junit.jar
  • ??IDE??,???????JUnit??????lib?,??????IDE?????? .

4
??JUnit
  • ???
  • ?3?????????,?????????????????????????,???
  • java junit.textui.TestRunner TestClass
  • ?????AWT?SWING????
  • java junit.awtui.TestRunner TestClass
  • ?
  • java junit.swingui.TestRunner TestClass

5
  • IDE
  • ?????????????,?IDE???JUnit?????,Eclipse???????
    ?,???????????????????TestCase?NetBeans???????????J
    Unit TestCase??

6
  • Ant????
  • Ant??????????????JUnit????????????,???????Test
    Case???????JUnit???XML??ltjunitgt???,???Ant?????????
    ???
  • ltjunitgt
  • lttest nameSimpleTestgt
  • lt/junitgt

7
??JUnit??
  • ??JUnit??????
  • ??junit.framework.TestCase
  • ??testltNamegt??????????
  • ?testltNamegt???,??????assertltConditiongt???????

8
  • JUnit?????1(assertltConditiongt)
  • assertEquals (String message,expected,actual)
  • assertNull(String message, Object o)
  • Or assertNotNull(..)
  • assertTrue(String message,boolean condition)
  • Or assertFalse(.)

9
  • JUnit?????2
  • assertSame(String message,expected,actual)
  • Or assertNotSame(..)
  • fail(String message)

10
  • ???????????
  • ????????????????setUp()
  • ???TestCase????????tearDown()
  • ???TestCase?,?????setUp()?tearDown()?????

11
??
  • Case1
  • Money.java
  • MoneyTest.java
  • MTestMain.java
  • ?????????
  • ?Eclipse?????

12
????(TestSuite)
  • JUnit?????????????????,??????????????,?????????
    ?????????,Junit???junit.framework.TestSuite?,?????
    ????TestCase??????TestRunner,???????????????

13
  • ???????TestCase,?????TestSuite???????,?????????
  • TestSuite suitenew TestSuite(Money.class)
  • ?????addTest?addTestSuite??????TestSuite????
  • TestSuite????Test?????,????????Test,?????????TestS
    uite?????,??????????TestSuite????,??????????TestSu
    ite??

14
  • ???TestSuite,????TestSuite????Test??????????TestSu
    ite,????????suite(??Test???)????Test??
  • ??
  • Case2(MTestMain1.java)
  • JUnit3.8.1????(junit)

15
?????????
  • JUnit???????????????????????????????????????TDD(?
    ?????)????????
  • ?????????
  • ????,?????
  • ????,???????????????
  • ??????,?????

16
  • ???JUnit???,????????????????????????????
  • ??????????????,???????
  • ??????????????,??????????
  • ??????,??????????????????
  • ????????,??????????

17
  • JUnit?????????????,??????????TestSuite?,??????
    ????????????,??????????????????????????????
Write a Comment
User Comments (0)
About PowerShow.com