What is JUNIT? Cherami original
JUnit is a Java test framework for development source code for writing and running repeatable tests. He is an instance for unit test framework system xUnit (for Java language). It includes the following characteristics: 1. Assertion 2 for testing the desired result 2, test tools for sharing co-test data, for easy tissue and run test test kit 4, graphics, and text test runners JUnit was originally written by Erich Gamma (one of the GOFs) and Kent Beck (one of the pioneers of XP and Refactor). The JUnit is generally used to perform unit test, so you need to understand the internal structure of the test code ( The so-called white box test), additional JUnit is a tool recommended in XP programming and reconstruction (refactor), because in the case of automatic unit testing, it can greatly improve the efficiency of development, but actually write tests. The code also takes a lot of time and energy, then where is the benefit of this stuff? The author thinks that this is: 1. For XP programming, the author requires writing test before writing code, so you can force you to think about the function and logic of the code (method) before writing code, otherwise the code written is unstable. Then you need to maintain test code and actual code at the same time, this workload will greatly increase. Therefore, in XP programming, the basic process is this: concept - "Write test code -" Write code - "test, and write testing and writing code is incremental, write a little test, in the next code If the problem can be discovered by the problem, it is similar to the problem of returning errors. It is similar to the benefits and XP programming. Because the reconstruction is also required to change a little measurement, reduce The time consumption caused by the regression error. 3. For non-above two cases, we use Junit to write some appropriate tests when developing, because usually need to write code code, may not use JUnit, if you use JUnit, and Interface (Method) Writing Test Code will reduce future maintenance, such as modifications within the method (this is equivalent to reconstruction). Also because JUnit has an assertion function. If the test result does not tell us that the test is not passed, why, and if you want the previous general practice to write some test code to see its output results, then to determine the results correctly The advantage of using JUnit is whether this result is correct. It is to be done. We only need to see if it tells us whether it is correct, and it will greatly improve efficiency in general.