????????????
???????????? ???????[ 2013/3/6 11:09:20 ] ????????
??????????????????????????????????????????????????????????????????????????????????????????????????????
????????????Unit Testing??????????????????????????е???????????????????????????ж??????????????????????????????????????????????????????????????????????“??????”???????????“??????”??????????????????????????????????????????????????????????е???飬??????????????????????????????????????????????У???????????????????????????????????????????????????嵽?????????????壬??????????????????????ι??????
???????????????????
????????????????????????XUnit?????????????????????????Java?????????JUnit??.Net????????????NUnit??????Щ???????????????????????Cantata??AdaTest????????????C/C++????????????????????Ada?????????????????????????????????????????
????????п?????????????????????????????????????????????????飬???б????????????????????????????????????????????漲???????????
?????????????????饗Stub Module??????????饗Drive Module??????????????????????????????????????????????????????????????????????е????????????????????????????????????????????????顣????????????У?????????????????????????????????????????????????????????????????????????????“??????”?????????????????????Щ???????????????????????н???????????顣?????????????????????????????????????У?????????????????????????????У?????????????????????????????????????顣?????????????????????????????н????????????飬????????????н????????????????????????E-mail?????????????????
??????????????????????Java???????????????????????????????????????????ɡ?????????CaseCheck.java??Account.java???MoneyTran.java??????CaseCheck.java????????飬Accout.java?????????????MoneyTran.java?????顣?????г??????????????
/* Module name: CaseCheck.java this module servers as driven module; */
public class CaseCheck{
public static void main(String[] args){
Account TomAccount=new Account(8000);
if(8000!=TomAccount.checkBalance()){
System.out.println("TomAccount Construction error!");}
System.out.println("Total balance of TomAccount is "+TomAccount.checkBalance() +"
Withdraw 1000 from TomAccount
"+TomAccount.withdraw(1000));
System.out.println("Now??total balance of TomAccount is "+TomAccount.checkBalance() +"
Withdraw 8000 from TomAccount
"+TomAccount.withdraw(8000));
System.out.println("Desopit 2000 to Tom's Account.");
TomAccount.deposit(2000);
if(9000!=TomAccount.checkBalance()){
System.out.println("Account class deposit method error!");}
System.out.println("Now Tom's Account has Rmb "+TomAccount.checkBalance()+" .It can change into USDollar "+TomAccount.toDollar());
}
}
/* Module name: Account.java this module servers as software unit for test; */
public class Account{
private int sum;
public Account(int num){
sum=num;
}
public String withdraw(int num){
if(num>sum){return "Overdraft.Operation cancelled."+"
";}else{
sum-=num;
return "Withdraw Success."+"
";}}
public void deposit(int num){
sum+=num;}
public int checkBalance(){return sum;}
public int toDollar(){
double rate=MoneyTran.RmbtoDollar();
return (int) (rate*sum);}
}
/* Module name:MoneyTran.java this module servers as stub module; */
public class MoneyTran{
static double RmbtoDollar(){return 0.12081964;}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11