简体   繁体   English

Django / Python:如何知道哪些测试覆盖了一段代码?

[英]Django/Python: how to know which tests cover a piece of code?

I know coverage python package is capable of creating reports (in html) that show if pieces of code are covered by tests, or not. 我知道覆盖python包能够创​​建报告(在html中),显示代码片段是否被测试覆盖。 I can also run just a single individual test, and know what does it covers. 我也可以运行一个单独的测试,并知道它涵盖了什么。

Is there any way I can reverse the analysis? 有什么方法可以扭转分析吗? I mean, run all my tests, choose a line of code, and know which tests are hitting that line of code? 我的意思是,运行我所有的测试,选择一行代码,并知道哪些测试符合这行代码?

This is a feature of coverage.py 5.0 alpha . 这是coverage.py 5.0 alpha的一个功能。 There's a more recent alpha that the a3 mentioned in the blog post. 博客文章中提到的a3有一个更新的alpha版本。 Give it a try and let me know how it works for you. 试一试,让我知道它对你有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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