1.下载fitnesse-standalone.jar

2.在cmd中输入,开启fitnesse server

初试FitNesse-LMLPHP

3、在浏览器中输入:

初试FitNesse-LMLPHP

4、编写代码:

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"

初试FitNesse-LMLPHP

遇到的大坑总结:

(1)define TEST_SYSTEM{slim}其中 TEST_SYSTEM与{slim}应该有空格

初试FitNesse-LMLPHP

(2)在引用时由于引用的类名(ShouldIBuyMilk)与 E:/fitnesse/fitnesse-standalone.jar中的ShouldIBuyMilk类重名所以出现如下错误:

初试FitNesse-LMLPHP

解决办法:编写一个不与其重名的类:ShouldIBuyMilk1,点击“Test”运行成功:

初试FitNesse-LMLPHP

05-07 15:08