Thursday 23 March 2023

Pytest usage in Pycharm

Setup Pytest in Pycharm for running test cases 

 1)Install pytest package from python interpreter option by navigating to preferences ---->python                       interpreter

2)Create new run/debug configuration for test cases wherein following information need to be given:

    2.1) Name of the run/debug give it as per your choice.

    2.2)  Target: This will the folder under which you want to run tests . It has different options like script,              custom etc.

          * Use script if want to execute all test cases under folder/project.

         * Use custom if want to make dynamic file selection like I did by passing --tb=1 as argument . This                will   pick current file and run test cases inside that file.

3)Working directory: This is last and mandatory to specify where to pick files from. 

4)Last change is make sure you are using pytest as test runner and it is selected in preferences-->Python Integrated Tools---->Testing--->Default test Runner --(pytest)


Below is step 2 configuration screenshot