Python CLI program unit testing

后端 未结 9 2213
日久生厌
日久生厌 2020-12-24 12:43

I am working on a python Command-Line-Interface program, and I find it boring when doing testings, for example, here is the help information of the program:

         


        
9条回答
  •  梦谈多话
    2020-12-24 13:13

    I would not test the program as a whole this is not a good test strategy and may not actually catch the actual spot of the error. The CLI interface is just front end to an API. You test the API via your unit tests and then when you make a change to a specific part you have a test case to exercise that change.

    So, restructure your application so that you test the API and not the application it self. But, you can have a functional test that actually does run the full application and checks that the output is correct.

    In short, yes testing the code is the same as testing any other code, but you must test the individual parts rather than their combination as a whole to ensure that your changes do not break everything.

提交回复
热议问题