如何继承 utx 的 TestCase 类编写测试用例
要继承 utx 的 TestCase 类,需要在编写测试用例时,将测试类继承自 utx 的 TestCase 类。
示例代码:
import utx
class MyTest(utx.TestCase):
def test_add(self):
self.assertEqual(1+1, 2)
if __name__ == '__main__':
utx.run()
在上面的例子中,MyTest 继承了 utx 的 TestCase 类,因此可以使用 utx 提供的各种断言方法进行测试。在运行测试时,使用 utx.run() 函数来执行测试用例。
原文地址: https://www.cveoy.top/t/topic/m8KA 著作权归作者所有。请勿转载和采集!