打算使用 nose+coverage 做自动化测试,并且查看测试用例对 webpy 程序的覆盖率是多少。目前测试用例是这么写的
from paste.fixture import TestApp from nose.tools import * from index import app class TestIndex(): def test_index(self): middleware = [] testapp = TestApp(app.wsgifunc(*middleware)) r = testapp.get('/') assert_equal(r.status, 200) def test_login(self): middleware = [] testapp = TestApp(app.wsgifunc(*middleware)) r = testapp.get('/login') assert_equal(r.status, 200)
但是覆盖率的结果是这样的
可以看到,测试覆盖率都是 test_index 这个文件本身,而不是引用的 index.py 。
我要看 test_index.py 里的测试用例对 index.py 里的接口覆盖率,应该如何编写测试用例。