JUNIT?? - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

JUNIT??

Description:

JUNIT JUNIT Junit TDD ... – PowerPoint PPT presentation

Number of Views:112
Avg rating:3.0/5.0
Slides: 15
Provided by: hg110110C
Category:
Tags: junit | junit

less

Transcript and Presenter's Notes

Title: JUNIT??


1
JUNIT??
2
?????????Junit,???????????????????????TDD(???????)
???,????????????Eclipse???????JUnit???????????Hell
o World???????? ????????????,?????????
?????????,??????????????????????,?????????????????
??????????,??????TDD,????(XP)?TDD???????,???????TD
D????????TDD????? ?????????,???????????????
??????????,??????????????? ??????,??????????
???????(?????Extreme Programming)?????????????,
??????????????????????,????(??)????????????????
3
??????????? ????????(????)???????????????????
?,?????,???????mock objects,???????????????????
????????????????????????????????XP?,??????????
???????????????????????????????????????????,moc
k objects????????,???????????,???????????????,????
??????????????????????????J2EE?????????????Cactus?
??????????????,????????????http//jakarta.apache.o
rg/cactus/? ??????????????????????????????????
??,?????,?????????????????????????????????
?????,??????,???????????? ??????????????,????
???????????????,??????Test?????????,???!?????
!???????????????
4
?TDD?,?????????????? ????????????,?????,??????
??????????????????? ????????,?????????????
???????????????,??????????,??????????????????,????
?,?????????????
5
???Eclipse??JUnit??????????????????????????Eclipse
????????,????????http//www.eclipse.org??????JUnit
,????http//www.junit.org/?????Eclipse?????workpl
ace??,????-gt??-gt??,??Java??,?????????????,??Projec
tWithJUnit?????????????????????????Eclipse,???????
?JUnit????????????-gt??,??Java????,?,??????JAR,??Ju
nit??????,??junit.jar,??????????JUnit?????????????
,?Eclipse?????
6
???????Hello World?????TDD???,??????????????????
???????,??????????HelloWorld,???????Say(),??????St
ring??(??Hello World!)? ????,?ProjectWithJUni
t?????????,????-gt??,??Java??,??JUnit????????????
?????,?????????1?
7
(No Transcript)
8
????????,??????????HelloWorld????????????,??TestTh
atWeGetHelloWorldPrompt(??,?????,??????????)?????
TestThatWeGetHelloWorldPrompt?????import
junit.framework.TestCasepublic class
TestThatWeGetHelloWorldPromptextends TestCase
public TestThatWeGetHelloWorldPrompt( String
name) super(name) public void
testSay() HelloWorld hi new HelloWorld()
assertEquals("Hello World!", hi.say())
public static void main(String args)
junit.textui.TestRunner.run( TestThatWeGetHelloW
orldPrompt.class)
9
?????????????????,???????????????JUnit?TestCase?,
??JUnit?javadocs?????????????JUnit??TestSuite?,?
??????????,?????????? ???????????
1?????junit.framework.TestCase????
2??????test????????(??testWasTransactionSUCcessf
ul(),testShow(),??)? TestThatWeGetHelloWorldPro
mpt.java????TestCase????????testSay()???????????a
ssertEquals()??,?????????????say()?????
main()???????????????JUnit?TestRunner????,????????
????????????????????,??Eclipse???,?????????????,??
???????????????,Eclipse????????????????????TDD??,
??????,?????????????-gt???-gtJunit??(??TestThatWeGet
HelloWorldPrompt.java????????????????)??????,????J
Unit???????????,???????,???????,??????????2???????
??????,??JUnit??(??????)?
10
(No Transcript)
11
??!????????????????????????????ProjectWithJUnit??
???,????-gt??????,?????????HelloWorld,??????????Hel
loWorld.java??????public class HelloWorld
public String say() return("Hello World!")
???????,???????,???????????????????,?JUnit??
?????????,???3??????????
12
(No Transcript)
13
??,???????????,????????????JUnit?????????????asser
tEquals()??,?Hello World!??Hello
Me!??????JUnit?,???????,?JUnit????????????,???4?
14
??,???????????????????????????????????????????????
?,?????????,????????????(??expectations-based
development??),???????????,?????????????????????,
?????????????????????,??????????
Write a Comment
User Comments (0)
About PowerShow.com