V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
larkifly
V2EX  ›  Python

最近在玩 Jenkins,使用 nose+coverage,如何查看 webpy 的测试用例对 webpy 所有接口代码的覆盖率了。

  •  
  •   larkifly · 2015-11-24 19:07:44 +08:00 · 1873 次点击
    这是一个创建于 3075 天前的主题,其中的信息可能已经有所发展或是发生改变。

    打算使用 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)
    

    但是覆盖率的结果是这样的
    Mou icon
    可以看到,测试覆盖率都是 test_index 这个文件本身,而不是引用的 index.py 。

    我要看 test_index.py 里的测试用例对 index.py 里的接口覆盖率,应该如何编写测试用例。

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5414 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 07:27 · PVG 15:27 · LAX 00:27 · JFK 03:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.