After reading the PHPunit assertions, I have some questions about the significance of PHPUnit? I can use a series of debugging methods such as var_dump to output the length of the variable type value. Do you need to determine what this is and write some assertions? Maybe I'm not familiar with PHPUnit in my experience... after reading the PHPunit assertions, I have some questions about the significance of PHPUnit? I can use a series of debugging methods such as var_dump to output the variable type, value, and length. Do you need to determine what this is and write some assertions?
Maybe I am not familiar with PHPUnit's deep application .. Which of the following experts can ask for help?
Reply content:
After reading the PHPunit assertions, I have some questions about the significance of PHPUnit? I can use a series of debugging methods such as var_dump to output the variable type, value, and length. Do you need to determine what this is and write some assertions?
Maybe I am not familiar with PHPUnit's deep application .. Which of the following experts can ask for help?
Var_dump is temporary, and phpunit is persistent and can be repeated.
It is impossible for you to add var_dump everywhere for the next full test?
Don't forget there is a mock to use together.
You think it can be replaced by var_dump. Maybe the business logic is too simple?
The classes I designed depend on external classes, and the class methods also need other internal methods for collaboration.
Different data inputs have different results. I cannot enter 10 pieces of data in the browser each time for testing.
Considering these 10 inputs, I will group the data into a group of data using a small method.
When performing a unit test on a small method, I only need to make some assumptions about its dependencies (assuming there is no bug in the dependency) and pass in the expected parameters (extreme and normal ), then, assert the returned results.
Finally, I will perform a unit test on the Interface opened to the outside, assuming that all the small Methods return data and assert that the data returned by this interface.
It can be seen that unit testing is still helpful for the design of the code structure.
Give a relatively simple instance https://github.com/Zizaco/confide/blob/master/tests/Confide/CacheLoginThrottleServiceTest.php
When performing unit tests on low-level classes such as repository, I only use assert for direct database operations ..
In the advanced class, we have all tested the repository, so we don't have to worry about database issues. Instead, we directly use the mock repository class.
I think you have the wrong question. It should be "why unit testing" and "why unit testing". You can google many answers.
It wasn't long before I was playing unit testing. I can't tell stub, spy, dummy, mock, double...
So let's just take a look at what I wrote above. Don't take it seriously... but if you have any mistakes, please correct them.
If you are still comparing PHPUnit and var_dump, it proves that you do not understand the advantages of unit testing! Find out the Unit Test Documents first.