Skip to content

Commit da1c6b0

Browse files
committed
翻译42.3.11 自动配置的Data MongoDB测试
1 parent 628de0f commit da1c6b0

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

IV. Spring Boot features/42.3.10 Auto-configured jOOQ tests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ public class ExampleJooqTests {
1818
private DSLContext dslContext;
1919
}
2020
```
21-
JOOQ测试类是事务型的,默认在每个测试结束时回滚。如果这不是你想要的结果,你可以按如上方式对一个测试或是整个类禁用事务管理:
21+
JOOQ测试类是事务型的,默认在每个测试结束时回滚。如果这不是你想要的结果,你可以按照[上面例子中的方式](./42.3.9 Auto-configured JDBC tests.md)对一个测试或是整个类禁用事务管理。
2222

2323
[附录](https://docs.spring.io/spring-boot/docs/2.0.0.M2/reference/htmlsingle/#test-auto-configuration)中可以查看`@JooqTest`开启的自动配置列表。

IV. Spring Boot features/42.3.11 Auto-configured Data MongoDB tests.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
###42.3.11 自动配置的Data MongoDB测试
2-
@DataMongoTest can be used if you want to test MongoDB applications. By default, it will configure an in-memory embedded MongoDB (if available), configure a MongoTemplate, scan for @Document classes and configure Spring Data MongoDB repositories. Regular @Component beans will not be loaded into the ApplicationContext:
1+
### 42.3.11 自动配置的Data MongoDB测试
32

3+
如果你想要测试MongoDB应用,你可以使用`@DataMongoTest`。默认的,它将会配置一个内存MongoDB(如果可能),配置一个`@MongoTemplate`,扫描`@Document`类和配置Spring Data MongoDB仓库。常规的`@Component`bean将不会加载进`ApplicationContext`
4+
```java
45
import org.junit.runner.RunWith;
56
import org.springframework.beans.factory.annotation.Autowired;
67
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
@@ -16,8 +17,9 @@ public class ExampleDataMongoTests {
1617

1718
//
1819
}
19-
In-memory embedded MongoDB generally works well for tests since it is fast and doesn’t require any developer installation. If, however, you prefer to run tests against a real MongoDB server you should exclude the embedded MongoDB auto-configuration:
20-
20+
```
21+
由于内存MongoDB快,而且不需要任何开发者安装,它总体上在测试中工作得很好。但是,如果你更喜欢在一个非真实的MongoDB服务器上运行你的测试,你应当排除内嵌的MongoDB自动配置:
22+
```java
2123
import org.junit.runner.RunWith;
2224
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
2325
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
@@ -28,4 +30,5 @@ import org.springframework.test.context.junit4.SpringRunner;
2830
public class ExampleDataMongoNonEmbeddedTests {
2931

3032
}
31-
A list of the auto-configuration that is enabled by @DataMongoTest can be found in the appendix.
33+
```
34+
[附录](https://docs.spring.io/spring-boot/docs/2.0.0.M2/reference/htmlsingle/#test-auto-configuration)中可以查看`@DataMongoTest`开启的自动配置列表。

0 commit comments

Comments
 (0)