|
最近一直在研究Jtest,都是全英文版的。看起来有点吃力。
现在在研究数据源的使用,当中遇到了一定的困难,希望大家一起来解决。
源代码是这样的:
package examples.bank;
public class BankAccount
{
public BankAccount (int customer_id, int initial_balance) {
_customerId = customer_id;
_balance = initial_balance;
}
public int getCustomerId () {
return _customerId;
}
public int getBalance () {
return _balance;
}
/**
* Performs a transaction on the bank account, deducting any transaction
* fees. Transaction may be a deposit, withdrawl, or a change of ownership.
*/
public void apply (Transaction transaction)
{
if (transaction instanceof Deposit)
apply0 ((Deposit) transaction);
else if (transaction instanceof Withdraw)
apply0 ((Withdraw) transaction);
else if (transaction instanceof ChangeOwnership)
apply0 ((ChangeOwnership) transaction);
_balance -= transaction.getTransactionFee ();
}
private void apply0 (Deposit deposit) {
_balance += deposit.getAmount ();
}
private void apply0 (Withdraw withdraw) {
_balance -= withdraw.getAmount ();
}
private void apply0 (ChangeOwnership co) {
_customerId = co.getNewCustomerId ();
}
private int _customerId;
private int _balance;
}
现在,我要在针对这个类生成的testcase中加入数据源。
加入的过程是这样的:
BankAccount(int,int)
input
Arguments
int customer_id=0
int initial_balance={deposit Amount}
Expected output
Outcome
Expected result: Nomal reutrn
BankAccount Outcome is instanceof BankAccount
BankAccount(int, int)
int customer_id=0
int initial_balance={Expected Balance($2 transaction fee)}
Arguments
int customer_id=0
int initial_balance={deposit Amount}
不知道这样的设置是否有错误.
[ 本帖最后由 marystone 于 2006-10-9 16:58 编辑 ] |
|