Junit4 uses detailed two: Junit4 running processes

1. Create a new test, the following four methods in order to see the effect checking

 

2. We write method in which each output statement

 

3. After the run we can see, it is this order of execution

 

NOTE: Running in the process junit4

1. @ BeforeClass modified method will be executed before any method is called, and the method is static, all classes are loaded when the test will then run it,
and it will exist an instance in memory, it more suitable to load configuration file
2. @ AfterClass the modified method is usually used to clean up resources, such as closing a database connection
3. @ Before and @After will be implementing before and after each test method once

 

Guess you like

Origin www.cnblogs.com/sukiysun/p/11007409.html