我有一个清理数据库和报表的功能。我希望每次运行测试(问题)时都运行这个函数,不管是运行一个测试(类中的方法)还是整个类。你知道吗
我的脚本是静态方法
@staticmethod
def startScript():
removeData()
removeReport()
My example test:
test.py
class myTesting(unittest.TestCase):
def test_add_new_user(self, name, elem1, elem2):
code my test.
如何在每次运行测试时添加一个脚本来运行它?谢谢你的帮助
将其作为固定装置添加到函数中
https://docs.pytest.org/en/latest/fixture.html
或将其添加到类中的setup\u方法中:
第三种方式: 将静态函数添加到确认测试.py在作用域中,此文件应与测试.py地址:
更多信息确认测试.py地址:
https://docs.pytest.org/en/2.7.3/plugins.html?highlight=re
相关问题 更多 >
编程相关推荐