Pytest 文件执行
在本章中,我们将学习如何执行单个测试文件和多个测试文件。我们已经创建了一个测试文件 test_square.py 。创建一个新的测试文件 test_compare.py ,代码如下:
现在,为了运行所有文件(这里有2个文件)中的所有测试,我们需要运行以下命令
上述命令将运行test _square.py 和 test_compare.py 的测试 。 输出将被生成如下 –
To execute the tests from a specific file, use the following syntax −
现在,运行以下命令 –
上述命令将只执行文件 test_compare.py 中的测试 。 我们的结果将是 —