JUnit in action (1)

Source: Internet
Author: User

I have been practicing TDD development methods for more than a year. I feel that I still cannot master it flexibly. I went to the bookstore on the 51 holiday and ran into the book JUnit in action. It was a pretty good deal, I believe it will give me a lot of inspiration for using nunit. Now I am going to take a look at it every day. I want to record it in a simple way and then summarize it.

1. The author is a consultant during the day, a developer of Open Source Software at night, and an active participant in Maven, Gump, and mockobject. (You can see why I am so weak !)
2. IfProgramIf a function of is not automatically tested, the function basically does not exist.
3. Each test method is named testxxx. (We can also use the testxxx () method to name it in nunit)
4. Keep the bar green to keep the code clean. (You must pass all existing test cases before developing any function)
5. Identify failures and errors in JUnit. Failure actually refers to assertion failure (easier to fix), and error refers to the occurrence of an exception (unpredictable, take it seriously ).
6. testcase will be runningEachCall setup before testing, andEachCall teardown after the test is complete. (If there are two test methods in a test class, setup and teardown are actually called twice)
7. Each test must be able to run in any order, and the unit test must be able to run in any order. (Most of the test tools rely on reflection to discover test methods, but reflection does not guarantee the order of method names .)

This is the time for today.

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.