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