@ -3552,24 +3552,23 @@ which references a URL (e.g., a path prefixed with `classpath:`, `file:`, `http:
@@ -3552,24 +3552,23 @@ which references a URL (e.g., a path prefixed with `classpath:`, `file:`, `http:
will be loaded using the specified resource protocol.
The following example demonstrates how to use `@Sql` at the class level and at the method
level within a JUnit 4 based integration test class.
level within a JUnit Jupiter based integration test class.
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@RunWith(SpringRunner.class)
@ContextConfiguration
@SpringJUnitConfig
@Sql("/test-schema.sql")
public class DatabaseTests {
class DatabaseTests {
@Test
public void emptySchemaTest {
void emptySchemaTest {
// execute code that uses the test schema without any test data
}
@Test
@Sql({"/test-schema.sql", "/test-user-data.sql"})
public void userTest {
void userTest {
// execute code that uses the test schema and test data
}
}
@ -3699,41 +3698,41 @@ executed in an isolated transaction. Although a thorough discussion of all suppo
@@ -3699,41 +3698,41 @@ executed in an isolated transaction. Although a thorough discussion of all suppo
options for transaction management with `@Sql` is beyond the scope of this reference
manual, the javadocs for `@SqlConfig` and `SqlScriptsTestExecutionListener` provide
detailed information, and the following example demonstrates a typical testing scenario
using JUnit 4 and transactional tests with `@Sql`. Note that there is no need to clean up
the database after the `usersTest()` method is executed since any changes made to the
database (either within the test method or within the `/test-data.sql` script) will
be automatically rolled back by the `TransactionalTestExecutionListener` (see
using JUnit Jupiter and transactional tests with `@Sql`. Note that there is no need to
clean up the database after the `usersTest()` method is executed since any changes made
to the database (either within the test method or within the `/test-data.sql` script)
will be automatically rolled back by the `TransactionalTestExecutionListener` (see
<<testcontext-tx,transaction management>> for details).
assertEquals("Number of rows in the [user] table.", expected, countRowsInTable("user"));
void assertNumUsers(int expected) {
assertEquals(expected, countRowsInTable("user"),
"Number of rows in the [user] table.");
}
}
----
@ -4095,9 +4094,8 @@ use of `@RepeatedTest` from JUnit Jupiter allows the test method to gain access
@@ -4095,9 +4094,8 @@ use of `@RepeatedTest` from JUnit Jupiter allows the test method to gain access
// use orderService from the test's ApplicationContext
// and repetitionInfo from JUnit Jupiter
@ -4194,37 +4192,33 @@ of the Servlet API>> available in the `spring-test` module. This allows performi
@@ -4194,37 +4192,33 @@ of the Servlet API>> available in the `spring-test` module. This allows performi
requests and generating responses without the need for running in a Servlet container.
For the most part everything should work as it does at runtime with a few notable
exceptions as explained in <<spring-mvc-test-vs-end-to-end-integration-tests>>. Here is a
JUnit 4 based example of using Spring MVC Test:
JUnit Jupiter based example of using Spring MVC Test: