单元测试的过程

单元测试

测试四部曲

1. 初始化数据
2. 执行要测试的业务 3. 验证测试的数据 4. 清理数据

class NowstagramTest(unittest.TestCase): def setUp(self):

app.config['TESTING'] = True self.app = app.test_client() print 'setUp'

    def tearDown(self):
        pass

def test_reg_logout_login(self):
assert self.register("hello", "world").status_code

== 200
assert '-hello' in self.app.open('/').data self.logout()
assert '-hello' not in self.app.open('/').data self.login("hello", "world")
assert '-hello' in self.app.open('/').data

你可能感兴趣的:(计算机基础)