简体   繁体   中英

How to get unit test coverage results in Eclipse + Pydev?

I know Eclipse + PyDev has an option Run As => 3 Python Coverage . But all it reports is:

Ran 6 tests in 0.001s

OK

And it says nothing about code coverage. How to get a code coverage report in Pydev?

  • Run a file with "Python Coverage"
  • Window > Show View > Code Coverage Results View
  • Select the directory in which the executed file is
  • Double-click on the executed file in the file list
  • Statistics are now at the right, not executed lines are marked red in the code view

Actually this is a really nice feature, didn't know about it before :)

请注意,在 pydev 2.0 中,覆盖支持发生了变化,现在,您应该首先打开覆盖视图并选择“为新启动启用代码覆盖”……之后,您所做的任何启动(常规或单元测试)都将具有正在收集覆盖信息(结果检查也变得更加直观)。

See if this helps http://www.machine-envy.com/blog/2006/07/29/automated-python-testing-with-nose-and-eclipse/

It uses nosetests with the –with-coverage option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM