Title: Test-Driven Development using FIT
1Test-Driven Development using FIT
2????????
- ??????Agile Development Conference 2003????? Ward
Cunningham????????????????????????????????????????
3Test-Driven Development
- ???????????FIT(Framework for Integrated
Test)?????????????????????????? - FIT???????????????????????????????????????????????
????????????????
4Guide Development
- FIT???????????????????????????????
- ????????????????????????????
5Refactoring
- TDD?????????Test-Driven-Design????????Refactoring?
???????????? - ???????????
6FIT
- FIT????????????test-table????????test-fixture?????
???? - Test-table??????????????????????
- Test-fixture?????test-table?????????????
7FIT??????????????
- FITNESSE?????
- FITNESSE???FITWiki??Wiki?????????????????????????
? - ?????????????Wiki????????????????????
8Install FIT(NESSE)
9FITNESSE???????
- http//fitnesse.org/??????????
- ?????sourceforge???
- ???v20030728?
- Fitnesse20030728.zip(????)
- Fitnesse_src20030728.zip(???)
- ???????????????
10FITNESSE???
- ?????????????Zip?????
- Java??????PC??????run.bat?????
- Java?http//java.sun.com/????????
- http//localhost/?????
11Fit Tasks
12FIT Test 30/360 Calendar
- ???????????1???30??1??360?????????(30/360Calendar?
??) - 30/360Calendar??????????????????
- ????????form, to, days()
- days()?from??to????????int?????
- ColumnFixture???????????????
- ??????????????????
13FIT Test 30/360 Calendar
fitsample.ThirtyThreeSixty fitsample.ThirtyThreeSixty fitsample.ThirtyThreeSixty
from to days()
2001/01/10 2001/01/20 10
2001/01/10 2001/02/10 30
2001/01/10 2002/01/10 360
2001/01/10 2002/12/25 705
14FIT 1. create new page
- 30/360?????????????????Wiki???????????????
- http//localhost/ FrontPage?????Edit???????Front
Page??????????? - ??????ThirtyThreeSixty?????Save????
- FrontPage??ThirtyThreeSixty???????????????????????
???????
15FIT 2. Edit Test
- ????????ThirtyThreeSixty????Edit???????????????S
ave???? - ???????????????????
- ?????????????????Fixture??????
ThirtyThreeSixty fromtodays() 2001/01/1020
01/01/2010 2001/01/102001/02/1030 2001/01/1
02002/12/25705 ---- ClassPath
16FIT 3. Config Test
- ThirtyThreeSixty????Properties???????Test?????
??Save????
17FIT 4. Add ClassPath
- ?????????????????????
- ThirtyThreeSixty????ClassPath???????Classpath????
Edit??????? - Save???FrontPage??ThirtyThreeSixty?????????
!path fit.jar !path fitnesse.jar !path sample
18FIT 5. Run Test
- ????????????????
- ?????????(ThirtyThreeSixty???)????????????????
- ?(???) ThirtyThreeSixty??????!!
19FIT 6. Create new class
- ThirtyThreeSixty??????????
- fitnesse/sample/fitsample?????ThirtyThreeSixty.jav
a????????????????
package fitsample import fit.ColumnFixture publ
ic class ThirtyThreeSixty extends
ColumnFixture
gt javac -classpath fit.jar -d sample
sample\fitsample\.java
20FIT 7. Re Run Test
21FIT 8. Create from-to Field
- from, to????????!?????????????????ThirtyThreeSixty
?????????? - ?????????????
package fitsample import fit.ColumnFixture impor
t java.util.Date public class ThirtyThreeSixty
extends ColumnFixture public Date from
public Date to
22FIT 9 Re-Re Run Test
- ????????????
- days()???????!????????????????
23FIT 10. Create days() Method
- days()??????????????????return 0
?????????????????????? - Save??????????
package fitsample import fit.ColumnFixture impor
t java.util.Date public class ThirtyThreeSixty
extends ColumnFixture public Date from
public Date to public int days()
return 0
24FIT 11. Re Re Re Run Test
- ????????????
- ??????????????????????????
- ?????????????(????0?????)??????????
25FIT 12. Fake IT
- ????????????????????????????????????return
10????? - Save?????????
package fitsample import fit.ColumnFixture impor
t java.util.Date public class ThirtyThreeSixty
extends ColumnFixture public Date from
public Date to public int days()
return 10
26FIT 13. RE4 Run Test
- ?????????????
- ??????????????????????
27FIT 14. Implementation
- ??????????????????????????????????????????????????
28??
- actualDays()????????????????
- ?????????????????????????????
- FIT?ColumnFixture???????????????????