What are unit tests and why should I care?

后端 未结 8 1437
礼貌的吻别
礼貌的吻别 2020-12-13 05:13

Okay, I develop web applications in PHP and JavaScript and a lot of times here on Stack Overflow I have seen the word unit test passing by, but nowhere on the websi

相关标签:
8条回答
  • 2020-12-13 05:47

    On why unit testing should be done in the first place, I would like to add the argument by Barry Boehm: "a fault discovered and corrected in the unit testing phase is more than a hundred times cheaper than if it is done after delivery to the customer."

    While the multiplier does sound a bit rough, I think the argument definitely justifies testing.

    0 讨论(0)
  • 2020-12-13 05:50

    A unit test is a test of a small portion of the code that you write. You test it in isolation from the rest of the system in order to ensure that that portion of your code works.

    It is easier to test a lot of small portions of code, ensure that they work, and then test them working together, rather than testing the system as a whole.

    It is important to distinguish between unit testing and automated unit testing. You should always unit test your code. However, automating your unit tests is a whole other subject.

    0 讨论(0)
提交回复
热议问题