1.下載fitnesse-standalone.jarjava
2.在cmd中輸入,開啓fitnesse server瀏覽器
三、在瀏覽器中輸入:this
四、編寫代碼:spa
package fitnesse.slim.test; import java.util.List; public class ShouldIBuyMilk1 { private int dolloars; private int pints; private boolean creditCard; public void setDolloars(int dolloars) { this.dolloars = dolloars; } public void setPints(int pints) { this.pints = pints; } public void setCreditCard(String vaild) { if(vaild=="yes"){ this.creditCard=true; }else{ this.creditCard=false; } } public String goToStore(){ if(pints==0&&(dolloars>2||creditCard)){ return "yes"; }else{ return "no"; } } public void execute(){} public void reset(){} public void table(List<List<String>> table){} }
5.在fitness頁面點擊「Add」->"Test case"3d
遇到的大坑總結:code
(1)define TEST_SYSTEM{slim}其中 TEST_SYSTEM與{slim}應該有空格server
(2)在引用時因爲引用的類名(ShouldIBuyMilk)與 E:/fitnesse/fitnesse-standalone.jar中的ShouldIBuyMilk類重名因此出現以下錯誤:blog
解決辦法:編寫一個不與其重名的類:ShouldIBuyMilk1,點擊「Test」運行成功:cmd