Best practices for unit testing

Source: Internet
Author: User

We have collected some best practices for unit testing and hope they will be of reference value to everyone.

  1. Test only one object at a time
  2. Select meaningful method name
  3. Explain the cause of failure in assert call
  4. One test method equals to one unit test
  5. Test anything that may fail
  6. Improve TestingCode
  7. Reconstruction
  8. Test first
  9. Do not write any business logic into mock objects
  10. Test only possible errors
  11. The simplest design that can be operated using TDD
  12. Throw an exception for an unimplemented Method
  13. Refactored lengthy code setting when using mock objects
  14. Refactoring test setup and teardown

Regardless of the scale of software development, dependency is a key issue in software development ...... RemoveProgramIn, that is, removing dependencies.Kent Beck, test driven development: by example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.