@BeforeClass acting on a class
Executes once for all methods in a class
property to be declared as static.
@Before Acting on methods
Every test method is executed once
@Test Join the test
JUnit order problem, performed alphabetically. To execute in an orderly manner, you can use testng,testng to add dependent
JUnit Union Spring
@RunWith (Springjunit4classrunner. Class) //Spring and JUnit connection @ContextConfiguration ({"classpath:/spring/ Applicationcontext-test3.xml "publicclass springtest { //reasource and Autowired is two ways to inject
@Resource//Search by name, belong to the Java EE, do not write by class find
PrivateJdbcTemplate JdbcTemplate;
//@Autowired//Search by type, belong to spring//private JdbcTemplate JdbcTemplate;
@Test PublicvoidTestgetuserbyid ()
{
Integer userId= 1; String SQL= "SELECT count (*) from T_user_test";
intcount = jdbctemplate.queryforobject (sql, Integer.class); System.out.println (count); }
}
@Autowired
JUnit Common and JUnit Union spring