gpt4 book ai didi

Spring @IfProfileValue 应该忽略测试类,但事实并非如此

转载 作者:行者123 更新时间:2023-12-04 13:22:06 24 4
gpt4 key购买 nike

因此,我尝试使用 @IfProfileValue 分离测试以在我的 CI 管道上运行。

我只是把这个注释放在我的一个测试类上,我还没有定义值。我只是想检查当我运行 mvn test 时,surefire 会忽略这个测试。

出于某种原因,测试被提取并执行。

@IfProfileValue(name = "test-profile", value = "something")
@RunWith(Parameterized.class)
@SpringBootTest
@WebAppConfiguration
public class MyTest {

最佳答案

要使测试使用 Spring 上下文,您需要使用 SpringRunner 运行它们。在您的示例中,您使用了 Parameterized runner,这使得测试忽略 Spring 上下文,因此 IfProfileValue 注释被忽略。

关于Spring @IfProfileValue 应该忽略测试类,但事实并非如此,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49799718/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com