Real Integration Tests with Testcontainers
您如何使用数据存储进行集成测试?
模拟不是一个选项,因为您想要测试实际的系统。
有一些内存中的实现,比如关系数据库的h2或hsqldb,但是对于您的生产系统仍然存在细微的差异,并且不是所有的数据存储都有内存中的类似项。
*在测试中使用实际的数据存储是可能的,但是管理它,并行运行测试,…远非理想。
那么解决方案是什么呢?有一些基于容器的非常整洁的解决方案,即Docker Maven插件和TestContainers。从您的测试中,您可以启动一个轻量级的、一次性的数据存储实例,本次讨论将指导您如何做到这一点。
展开查看详情
1. Philipp Krenn @xeraa Real Integrat- ion Tests with
2.Infrastructure | Developer
3.Integration Tests
4.
5.
6. But the unit tests passed, so... https://twitter.com/Aaronius/status/ 933497253347463168
7.
8.
9.
10.
11.Mocking
12.Mockito, EasyMock, JMock,...
13.
14. Ich mock mir die Welt widdewidde wie sie mir gefällt
15.! Unit tests, systems not under ! your control Test real datastore
16.In-Memory
17.H2, HSQLDB, Apache Derby,...
18.
19.Embedded Elasticsearch unsupported in 5.0+ https://www.elastic.co/blog/elasticsearch-the-server
20. ! Often ! good enough Test real datastore, supported systems
21. Actual Datastore
22.Local installation Docker container Cloud
23.Demo
24.! "Good ! old approach" External dependency, parallelization
25.In-Process
26.de.flapdoodle. embed.process https://github.com/flapdoodle-oss/ de.flapdoodle.embed.process
27....will provide a platform neutral way for running processes in unittests.
28. → MongoDB de.flapdoodle.embed.mongo → Redis de.flapdoodle.de.embed.redis → Memcached de.flapdoodle.embed.memcached → PostgreSQL ru.yandex.qatools.embed → MySQL com.wix.mysql → Consul com.github.golovnin.embedded.consul → Vault com.github.golovnin.embedded.vault → InfluxDB io.apisense.embed.influx
29.Build Tool