JUnit Common and JUnit Union spring

Source: Internet
Author: User
Tags testng

@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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.