Merge branch '1.5.x'
This commit is contained in:
@@ -5294,7 +5294,7 @@ Data JPA repositories. Regular `@Component` beans will not be loaded into the
|
||||
`ApplicationContext`.
|
||||
|
||||
Data JPA tests are transactional and rollback at the end of each test by default,
|
||||
see the {spring-reference}#testcontext-tx-enabling-transactions [relevant section] in the
|
||||
see the {spring-reference}#testcontext-tx-enabling-transactions[relevant section] in the
|
||||
Spring Reference Documentation for more details. If that's not what you want, you can
|
||||
disable transaction management for a test or for the whole class as follows:
|
||||
|
||||
@@ -5372,6 +5372,42 @@ A list of the auto-configuration that is enabled by `@DataJpaTest` can be
|
||||
|
||||
|
||||
|
||||
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-jdbc-test]]
|
||||
==== Auto-configured JDBC tests
|
||||
`@JdbcTest` is similar to `@DataJpaTest` but for pure jdbc-related tests. By default it
|
||||
will also configure an in-memory embedded database and a `JdbcTemplate`. Regular
|
||||
`@Component` beans will not be loaded into the `ApplicationContext`.
|
||||
|
||||
JDBC tests are transactional and rollback at the end of each test by default,
|
||||
see the {spring-reference}#testcontext-tx-enabling-transactions[relevant section] in the
|
||||
Spring Reference Documentation for more details. If that's not what you want, you can
|
||||
disable transaction management for a test or for the whole class as follows:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.autoconfigure.jdbc.JdbcTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@JdbcTest
|
||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
public class ExampleNonTransactionalTests {
|
||||
|
||||
}
|
||||
----
|
||||
|
||||
If you prefer your test to run against a real database, you can use the
|
||||
`@AutoConfigureTestDatabase` annotation the same way as for `DataJpaTest`.
|
||||
|
||||
A list of the auto-configuration that is enabled by `@JdbcTest` can be
|
||||
<<appendix-test-auto-configuration#test-auto-configuration,found in the appendix>>.
|
||||
|
||||
|
||||
|
||||
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-client]]
|
||||
==== Auto-configured REST clients
|
||||
The `@RestClientTest` annotation can be used if you want to test REST clients. By default
|
||||
|
||||
Reference in New Issue
Block a user