"Test-Driven Development - A Practical Guide" Reading Note - Chapter 4

xiaoxiao2021-03-05  24

Chapter 4: JUnit

1. General writing method sequence as follows: Precondition - Perform the function to be tested - the postcondition. It is best to prepare the test when the test is written: Assertion, the assertion-written code to generate this result - set any pre-condition (can be labeled by [SETUP] to launch a method).

2. Always pay attention to the taste of the test code (SMEL), and reconstruct the test code when needed.

3. When using TestSuite, TestCase should be independent of each other.

4. You should write TestCase instead of method, and a test method test should be a single behavior.

5. TestCase is a mechanism that allows reusing preset environments. All test methods must use the preset environment.

6. TestSuite is an organization a set of TESTs and sequentially performing their mechanisms.

7. Test code home: can be together with the measured code, or in the subcap (Subpackage).

8. Test your simple things, easy to test things, and something.

9. Use the message parameter in Assertion.

10. To maintain a short test method, it is important to make the number of assertions in each test method.

11. Test the boundary conditions as soon as possible, such as NULL, empty strings, 0 and max_int. These Easy Tests of the Tester's Block.

12. Maintaining the inter-test inter-test, a test, success and failure cannot affect the results of other tests.

13. The extracted interface must be short, the goal is to be special, generally do not exceed three.

14. Avoid manually add information to the screen when testing because information waste is prone to.

15. Avoid using databases and network resources when testing.

16. When writing a test, you should start from the content (assertion) of the test (assertion), and then pour the settings needed to assert the assertion.

17. Write the appropriate TSTRING method.

转载请注明原文地址:https://www.9cbs.com/read-36166.html

New Post(0)