@Commit

@Commit 表示在测试方法完成后应提交事务性测试方法的事务。你可以使用 @Commit 直接替换 @Rollback(false),以便更明确地传达代码的意图。类似于 @Rollback@Commit 也可以声明为类级别的或方法级别的注释。

@Commit indicates that the transaction for a transactional test method should be committed after the test method has completed. You can use @Commit as a direct replacement for @Rollback(false) to more explicitly convey the intent of the code. Analogous to @Rollback, @Commit can also be declared as a class-level or method-level annotation.

以下示例展示了如何使用 @Commit 注释:

The following example shows how to use the @Commit annotation:

Java
@Commit (1)
@Test
void testProcessWithoutRollback() {
	// ...
}
1 Commit the result of the test to the database.
Kotlin
@Commit (1)
@Test
fun testProcessWithoutRollback() {
	// ...
}
2 Commit the result of the test to the database.