我正在使用python覆盖范围来确定以下文件的行覆盖范围
coverage report -m math_test.py
运行命令后,我最终覆盖了0行。
import example
import pytest
import unittest
class SampleTest(unittest.TestCase):
def testAddition(self):
expected = 10
math_addition = example.add(5,5)
self.assertEqual(math_addition, expected)
def add(x,y):
return x+y
运行Math_test.py不会做任何事情。它定义了类和功能,但对其中的任何一个都没有任何作用。Coverage.py不是测试跑者。您需要使用pytest或Unitest之类的东西来运行测试:
coverage run -m unittest discover
coverage report -m