I have a preliminary understanding of PHPUnit. I feel that unit testing is to use a test class to simulate entering a form in a browser and submitting a form to test whether the normal operation is successful. The function test is not available yet. I think, isn't PHPUnit very useful for a small website? What should I do?
PHPUnit, Feeling
Unit TestA test class is used to simulate entering a form in a browser and submitting a form to test whether the normal operation is successful.
Function TestingNot yet understood.
I think, isn't PHPUnit very useful for a small website?
What scale should I use PHPUnit to achieve?
I think PHPUnit cannot test some potential risks and bugs (submit unexpected form data, etc ). Isn't it better to open your browser to test a test class?
In addition, it can be said that PHPUnit has experience and feelings.
Reply content:
Have a preliminary understandingPHPUnit, Feeling
Unit TestA test class is used to simulate entering a form in a browser and submitting a form to test whether the normal operation is successful.
Function TestingNot yet understood.
I think, isn't PHPUnit very useful for a small website?
What scale should I use PHPUnit to achieve?
I think PHPUnit cannot test some potential risks and bugs (submit unexpected form data, etc ). Isn't it better to open your browser to test a test class?
In addition, it can be said that PHPUnit has experience and feelings.
First of all, let's answer your first question. unit test you said that you could use the browser form to simulate the submission. This is not an error. However, using the form to simulate the submission may not cover all your code logic, unit testing focuses on coverage. Generally, regular enterprises require a coverage rate of over 80%;
Second, IF Manual Interference is required for each unit test, this unit test is meaningless. Generally, you write your modules and then write the test code separately, the subsequent steps will be completed by the tool "continuous integration". You only need to submit an SVN version number, and then go back from work. The next day, after the continuous integration is completed, it will list the unit test results and some other code problems, such as the complexity of the circle, the number of lines of code, and so on...
Third, General small websites do not need to waste time writing unit tests, because unit tests are very time-consuming. Generally, the time for business writing is. Therefore, for large websites, A high security requirement, or a unit test script is written only when the modules at the application layer need to be split. Otherwise, it is impossible for a small company to spend the time doing this, after all, the time cost is equivalent to the programmer's salary.
I don't know if this answer solves your doubts?