IKo*_*IKo 11 java testing spring-boot
我有两个配置文件:dev和default.当活动配置文件是默认时,我想跳过一些(不是全部)测试.有可能以某种方式标记这些测试吗?或者如何实现这一目标?我用springboot.这是我的父测试类:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MyServiceStarter.class, webEnvironment= SpringBootTest.WebEnvironment.DEFINED_PORT,
properties = {"flyway.locations=filesystem:../database/h2", "server.port=9100", "spring.profiles.default=dev"})
@Category(IntegrationTest.class)
public abstract class AbstractModuleIntegrationTest { ... }
Run Code Online (Sandbox Code Playgroud)
IKo*_*IKo 10
我的同事找到了一个解决方案:所以如果你需要注释单独的测试,你可以使用@IfProfileValue
注释:
@IfProfileValue(name ="spring.profiles.active", value ="default")
@Test
public void testSomething() {
//testing logic
}
Run Code Online (Sandbox Code Playgroud)
此测试仅在默认配置文件处于活动状态时运行
是的,你可以做到。
例如使用@ActiveProfiles
:
@ActiveProfiles("default")
@RunWith(SpringRunner.class)
@SpringBootTest
public class YourTest {
//tests
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2361 次 |
最近记录: |