如何在springboot中创建用于集成测试的liquibase变更集? [英] How to create liquibase changeset for integration tests in springboot?
本文介绍了如何在springboot中创建用于集成测试的liquibase变更集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要通过liquibase变更集进行集成数据测试的模拟数据,如何使其不影响真实数据库?我从
I want mock data for integration tests by liquibase changeset, how to make that to not affect real database? I found partial idea from here, but I am using springboot and I hope there is simpler solution.
推荐答案
您好,您可以使用liquibase的context参数.例如,创建更改集,该更改集将从sql文件中加载插入内容,并为其指定上下文.
Hi you can use liquibase's context parameter. For example create changeset which will have inserts loaded from sql file and specify the context for it.
类似这样的东西:
<changeSet id="test_data_inserts" author="me" context="test">
<sqlFile path="test_data.sql" relativeToChangelogFile="true" />
</changeSet>
并在用于测试的弹簧靴application.properties
中指定属性liquibase.contexts=test
.
and in spring boot application.properties
for test specify property liquibase.contexts=test
.
这篇关于如何在springboot中创建用于集成测试的liquibase变更集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文