Spring TestContext Test Framework

Source: Internet
Author: User

1. Note-based TestContext test framework, which uses annotation technology to make Pojo a spring test case that can run under a test framework such as Junit3.8 Junit4.4 testng

2. Direct use of junit to test the shortcomings of the spring program

1). Causes Spring container Multiple initialization issues

Depending on the invocation process of the JUnit test case, each execution of a test method will recreate a test case instance and invoke its setup () method.

Because in general, we initialize the spring container in the Setup () method, which means how many test methods are in the test case and how many times the spring container will be initialized again.

2). You need to manually get the bean by using the encoding method

3). Database threads are vulnerable to corruption

4). It is not easy to access the database under the same transaction to verify the correctness of business operations

  The Spring test framework is designed for testing based on spring framework applications, and it makes it easy to combine test cases with the spring framework, all of which can be solved.

3.TestContext core classes, support classes, and annotation classes

The core of the TestContext testing framework is composed of three org.springframework.test.context packages, namely TestContext and Testcontextmanager classes, and

Spring TestContext Test Framework

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.