class TestTransfer(unittest.TestCase): user1 = None user2 = None bank = None def setUp(self) -> None: self.user1 = User() self.user2 = User() self.bank = Bank() def test_transfer1(self): # 1.准备数据 self.user1.setAccount("qqq666") self.user2.setAccount("jen666") self.user1.setPassword("123456") self.bank.setMoney(666) # 2.预期结果 teststart = 0 # 3.调用被测方法 start = self.bank.bank_transfer(self.user1.getAccount(), self.user2.getAccount(), self.user1.getPassword(), self.bank.getMoney()) # 4.断言 self.assertEqual(teststart, start)
def addMoney(): User.setAccount(Utils.inputHelp("账号")) Bank.setMoney(Utils.inputHelp("存储金额")) start = Bank.bank_addMoney(User.getAccount(),Bank.getMoney()) if start == 1: print("存入成功!") if start == False: print("您输入的账号不存在!")
def withdrawal(): User.setAccount(Utils.inputHelp("账号")) User.setPassword(Utils.inputHelp("密码")) Bank.setMoney(Utils.inputHelp("要取出的金额")) start = Bank.bank_withdrawal(User.getAccount(),User.getPassword(),Bank.getMoney()) if start == 0: print("取款成功!") if start == 1: print("账号不存在!") if start == 2: print("密码不对") if start == 3: print("账户余额不足")
class TestAddMoney(unittest.TestCase): user = None address = None bank = None def setUp(self) -> None: self.user = User() self.bank = Bank() self.address = Address() def test_addMoney1(self): # 1.准备测试数据 self.user.setAccount("kkk666") self.bank.setMoney("666") # 2.预期结果 teststart = 1 # 3.调用被测方法 start = self.bank.bank_addMoney(self.user.getAccount(), self.bank.getMoney()) # 4.断言 self.assertEqual(teststart, start)
class TestWithdrawal(unittest.TestCase): user = None bank = None def setUp(self) -> None: self.user = User() self.bank = Bank() def test_Withdrawal1(self): # 1.准备数据 self.user.setAccount("qqq666") self.user.setPassword("123456") self.bank.setMoney("1111") # 2.预期结果 teststart = 0 # 3.调用被测试方法 start = self.bank.bank_withdrawal(self.user.getAccount(), self.user.getPassword(), self.bank.getMoney()) # 4.断言 self.assertEqual(teststart, start)