【发布时间】:2019-07-01 09:56:33
【问题描述】:
我有一个应用程序,它使用"spring.profiles.active" 来决定使用哪个配置文件。我们正在使用 JUnit 4。我需要根据使用的 Profile 来调整我的测试类。所以如果"spring.profiles.active" = "X"我需要在A类中执行测试,如果"spring.profiles.active" = "Y"我需要在B类中执行测试。
我尝试过使用
@IfProfileValue(name="spring.profiles.active", value="X")
但是带有上述注解的类永远不会被执行。
System.Properties()
System.getProperties(){java.runtime.name=Java(TM) SE Runtime Environment, sun.boot.library.path=<<Masked>>, java.vm.version=25.191-b12, java.vm.vendor=Oracle Corporation, java.vendor.url=http://java.oracle.com/, path.separator=;, java.vm.name=Java HotSpot(TM) 64-Bit Server VM, file.encoding.pkg=sun.io, user.country=US, user.script=, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=, java.vm.specification.name=Java Virtual Machine Specification, user.dir=<<Masked>>, java.runtime.version=1.8.0_191-b12, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, , os.arch=amd64, spring.profiles.active=X
【问题讨论】:
标签: java spring junit spring-profiles