1, what is JUnit
JUnit is a unit test framework for the Java language. Founded by Kent Beck and Erich Gamma, it became the most successful of the Xunit family of Sunit from Kent Beck. JUnit has its own JUnit expansion biosphere. Most Java development environments have integrated JUnit as a unit test tool.
JUnit is a regression testing framework (regression testing framework) written by Erich Gamma and Kent Beck. JUnit testing is a programmer's test, the so-called white-box test, because the programmer knows how the software being tested (how) accomplishes the function and what it does. JUnit is a set of frameworks that inherit the TestCase class and can be automatically tested with JUnit. [1]
2,. JUnit's test code writing idea
The test code in JUnit requires writing the test code before writing the code, and then writing the code and testing the code constantly in the idea-writing test code-programming-test, which reduces the amount of testing and modification and makes it easier to spot bugs.
If you test after you complete the code, it can be difficult to test or correct.
3,junit's trial
I started trying to install the JUnit 4.10.jar package, but since the environment variable configuration problem has not been successful, I saw in my blog that I was referred to as having inherited junit in eclipse, eliminating the hassle of configuring the library. So I did the following test [2]
4, Experience
1, the test case must be annotated with @test. @before is executed before each test method starts and is used for initialization, @after is executed after each test method is completed, and is used to clean up resources.
2, it is difficult to write test code, but this kind of thinking is very important to the programmer, I believe in the habit of writing test code for the future development will be a great help.
3, because Eclipse integrates JUnit and provides support for JUnit's operations, it is convenient to try JUnit in Eclipse.
Software Testing: JUnit