![](/img/trans.png)
[英]JUnit 5 with Spring boot - how repeat test with different profiles?
[英]Conditional JUnit 4 test execution based on Spring profiles
我有一個使用"spring.profiles.active"
來確定要使用的配置文件的應用程序。 我們正在使用JUnit4。我需要根據使用中的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
希望您在類級別添加了@IfProfileValue(name =“ spring.profiles.active”,value =“ X”)。嘗試在類中添加測試方法並進行檢查。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.