我想用Python中的Selenium RC执行测试套件。在这组测试中,我想:借助Selenium模拟用户在网站上输入的数据
检查数据是否正确地放入数据库
从所选帐户获取电子邮件并对其进行分析以检查数据是否正确
原则上所有测试都已完成,但它们并不作为包含这三个测试的整个测试套件工作。我试图用设置方法生成数据,但在所有测试中,数据都是不同的。我已经了解到在每次测试执行中setUp()和tearDown()方法都会运行,所以我试图将数据生成器移到测试类构造函数中,但我仍然无法处理它。在
我的测试结构如下:class TestClass(unittest.TestCase):
def __init__(self, TestClass):
unittest.TestCase.__init__(self, TestClass)
self.define_random_data()
def setUp(self):
db_connection_function(self)
def some_internal_methods(self):
...
def test_website_data_input(self):
...
def test_db_test(self):
...
def test_email_parse(self):
...
def tearDown(self):
...
suite = unittest.TestLoader().loadTestsFromTestCase(TestClass)
unittest.TextTestRunner(verbosity=2).run(suite)
我做错什么了?在每个测试中生成的数据都是不同的,我不知道如何处理它-我试着在每个可能的地方运行这个方法,但它仍然是错误的。在