Advertisement

该测试用例包含一个setUp方法和两个实例化的测试函数。

阅读量:
复制代码
 #coding=utf8

    
 '''
    
 用过调用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 

全部评论 (0)

还没有任何评论哟~