steps:
1. New package (generally named *. Test, the testing class and the development class are placed in different packages)
2. New JUnit Text case (generally named *test)
3. Select the method you want to test
4. You can download the latest jar package, or you can select the system's own: www.junit.org Static Introduction:import
static org.junit.assert.*; a
static class (not a jar package) is introduced in the test program, which is the import static org.junit.assert.*, where assert is the meaning of the assertion (judgment), and we can use the functions in this class to implement the judgment function. The
benefit of introducing this class is that assertequals (8,z) can be used directly in the following statement without the need to add an assert.
use Assertequals (8,z); The benefits of assertions:
(1) The color of the progress bar (bar) can be visualized to determine whether the test passed;
(2) If there are two methods, you can run at the same time, which is not done with main test;
(3) You need to manually judge, the program automatically complete the judgment.
Note: After a static introduction, you do not need to precede the corresponding class as long as you directly take advantage of the method.
junit--Unit Test Steps