'''
用过调用setUp()函数实现初始化代码。
当运行测试的使用,测试架构自动调用setUp()
在测试运行时,如果setUp()出现一个异常,框架将认为测试出现错误,测试代码将不被执行。
'''
from unittest import TestCase,main
from source.calcutor import calculatorClass
class withSetUp(TestCase):
def setUp(self):
self.cal=calculatorClass(25,45678)
def testCheckInitValue(self):
self.assertEqual(self.cal.first, 25, "Incorrect the init values,the value should be 10")
self.assertEqual(self.cal.second, 45678, "Incorrect the init values,the value should be 20")
def testAdd(self):
addvalue=self.cal.add()
self.assertEqual(addvalue, 45703, "Incorrect the add result ,the result should be 45703")
if __name__=="__main__":
main()