【发布时间】:2018-11-08 20:48:30
【问题描述】:
我有 3 个 maven 项目 A、B、C。A 是 B 的父项目,B 是 C 的父项目。所有 配置文件都在项目 A 的 pom.xml 中定义。
在项目 C 中,我正在尝试根据所选配置文件在 spring-test-context(在 src/test/resources 下)中选择属性文件。对于 回归测试,我们有 2 个属性文件:
- application-test-local.properties
- application-test.properties
在我们的 Windows 开发系统上,选定的配置文件将是“本地的”,并相应地在服务器上。选择“本地”配置文件时,应使用@ 987654322和application-test.properties否则在测试弹簧上下文中。在project C,在spring-test-context.xml,我试过了:
<beans profile="docker">
<util:properties id="metaDbProps" location="application-test-local.properties"/>
</beans>
<beans profile="default">
<util:properties id="metaDbProps" location="application-test.properties"/>
</beans>
但是,当我尝试 "mvn clean test -Pdocker" 时,应用程序似乎无法将选定的 maven 配置文件传递给 spring 配置文件,并且它总是从“默认”配置文件。
知道要解决什么问题以将 maven 配置文件传递给 spring 配置文件,以便它可以获取正确的属性文件吗?
为了便于理解,以下是项目 A 中配置文件的定义方式:
<profiles>
<!-- Windows development -->
<profile>
<id>docker</id>
<activation/>
<properties>
<INSTALL_MACHINE_LIST>localhost</INSTALL_MACHINE_LIST>
<COPY_MODE>local</COPY_MODE>
</properties>
</profile>
<!-- Development -->
<profile>
<id>dev</id>
<activation/>
<properties>
<INSTALL_MACHINE_LIST>dev01</INSTALL_MACHINE_LIST>
</properties>
</profile>
<!-- QA -->
<profile>
<id>qa</id>
<activation/>
<properties>
<INSTALL_MACHINE_LIST>dqa01</INSTALL_MACHINE_LIST>
</properties>
</profile>
<!-- Production -->
<profile>
<id>prod</id>
<activation/>
<properties>
<INSTALL_MACHINE_LIST>prod01</INSTALL_MACHINE_LIST>
</properties>
</profile>
</profiles>
【问题讨论】:
-
回归测试、单元测试或集成测试是什么意思?它是如何通过surefire插件调用的?最后,为什么你有两套测试用例,你不是只想在测试阶段测试所有东西吗?