小编lau*_*aur的帖子

@DirtiesContext在每个黄瓜测试场景之后都撕裂上下文,而不是上课

黄瓜执行的集成测试往往会留下导致后续测试出现问题的上下文。显而易见的解决方案似乎是Spring的解决方案@DirtiesContext,但是它并没有在运行完所有黄瓜功能之后就删除上下文,而是在每种情况下都执行了此操作,因此使测试执行时间相当长。也尝试过@TestExecutionListeners,但没有运气。

@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration( classes = { MyApplication.class, MyTestComponent.class }, loader = SpringApplicationContextLoader.class )
@ActiveProfiles( { "test", "someotherprofile" } )
@DirtiesContext( classMode = DirtiesContext.ClassMode.AFTER_CLASS )
@WebIntegrationTest( randomPort = true )
public class StepDefs extends StepDefUtils {
    // givens, whens, thens
Run Code Online (Sandbox Code Playgroud)

我是否试图以不受支持的方式使用DirtiesContext?

java spring integration-testing cucumber-jvm spring-boot

5
推荐指数
1
解决办法
1219
查看次数