Different ways of executing the pytest files

1. To execute all the files in a package we need to use the below command

pytest

2. To execute only a specific file then we need to use the file name along with the pytest command.

pytest test_FileName.py

3. To execute any function in the class then we need to specify class name along with function name and ‘::’ in between the class name and function name.

pytest test_FileName.py::test_method