Recently look at the code of a project and see that the project has a test program for each class. Because I need to use a part of the project code to do the test, I think I can use the same method, write a test program for that part. However, it is not possible to later find that the JUnit test package needs to be used in a development environment like Eclipse or maven (just my understanding) because the JUnit test package needs to be downloaded. Therefore, the final implementation is to re-write a class containing the main () function, modify the Pom.xml in the main () function entry.
My understanding is that JUnit writes a ubiquitous interface for the test, such as the main () function interface, which only needs to be written in a specific part of the customer's use.
Most Java development environments have integrated JUnit as a unit test tool, and JUnit testing is a programmer test, known as white box testing, because programmers know how the software being tested (how) accomplishes the function and what it accomplishes. JUnit is a set of frameworks that inherit the TestCase class and can be automatically tested with JUnit.
In addition, JUnit is a highly recommended tool in extreme programming and refactoring (refactor). What is extreme programming? Requiring you to write tests before you write code that forces you to think about the functionality and logic of your code before you write code, otherwise the code you write is very unstable, and you need to maintain both the test code and the actual code, and the workload will be greatly increased. So in extreme programming, the basic process is this: the concept of writing test code----write code--test, and write test and write code are incremental, write a little bit, in the code after writing, if you find the problem can quickly trace the cause of the problem, Reduces the difficulty of error correction for regression errors.
Note the following points:
1, the use of simple @Test annotations to achieve our test method of writing and execution
2. Use @test's Ignore property to specify that the test skips a method
3, the use of annotations @Before and @After to complete the pre-work and post-work
4. Use @test's attribute timeout to complete time-limited testing to detect dead loops in the code
5. Use @test property expected to monitor certain exceptions that may be thrown in test methods
6. Specify the Runner when JUnit runs the test case
7, TestNG may be used for a large number of data testing
Refer to these links for details:
https://my.oschina.net/bairrfhoinn/blog/167636
http://mark-yang.github.io/blog/2015/05/17/junit/
The JUnit test package for Java is unit tested