1 Write a test class and simply understand how junit can be partially used to replace Java's Main method
2 Add annotations on the test class method @Test
3 @Test Modified method requires: Publicvoid Method name () {...}, method name custom recommendation test begins with no parameters. That is, JUnit can only run the modifier to public and return the null argument method with the value type void .
@Before: Executed before the unit test @Test can be used to get some resources
@After: Executes after the unit test @Test and can be used to use some resources
Note : @Before and @After cannot be executed separately , run @Test they will automatically execute
4 Execution :
Select the method you want to execute , right-click run as-->junit Test
Execute multiple methods at once: Select Class , right-click run as-->junit Test
JUnit Unit test of Java EE