如何为 E2E 测试包含 Python 实用程序的覆盖率

问题描述

我有一个类似的python模块

TEST/testClass.py
class testClass.py:
     def __init__(self):
         <code>
     def fun1(self):
         <code>
     def fun2(self):
         print("executed")
         <code>

Utility: Util.py
import testClass.py
obj = testClass()
obj.fun1()
obj.fun2()

E2E tests:
from  subprocess import Popen
import unittest
class Test:
    def test_exec(self):
        Popen(["Util.py"],stdout=PIPE,stderr=PIPE,cwd=exeDir,shell=shell)
        (stdoutdata,stderrdata) = popenHandle.communicate()
        output = stdoutdata.decode('utf-8') + stderrdata.decode('utf-8')
        self.assertRegex(output,rf"executed")

if __name__ == '__main__':
   unittest.main()

#1: 那么在运行端到端测试时,如何为 testClass.py 和 Utils.py 生成 stmt、分支和功能覆盖率 现有的覆盖模块不考虑 Utils 和 testClass 进行覆盖计算,因为我们在 Popen 下运行该实用程序。无论如何要在 Utils.py 中包含一些开关(类似于使用 $HARNESS_PERL_SWITCHES 的 perl E2E 测试)以在 E2E 测试期间包含 python 覆盖率。

#2:功能覆盖也无法通过覆盖模块报告获得。如何获得python的功能覆盖?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...