Reset Spring-Boot During Integration Tests

て烟熏妆下的殇ゞ 提交于 2019-12-06 11:15:48

take a look at DirtiesContext

Not sure if this is what you're looking for.

Possible duplicate of: How do you reset Spring JUnit application context after a test class dirties it?

Whow, I think I just found out by accident... What I have now:

@RunWith(SpringRunner.class)
@EnableAsync
@SpringBootTest(webEnvironment = WebEnvironment.NONE, classes = {
    ClassWithAnAutowiredAsyncDependency.class // <=== difference!!! ===>
})
public class MyITest {
:
  @Autowired
  private ClassWithAnAutowiredAsyncDependency mine;
:
}

It seems as if the given classes are reset (specially?) or at least the autowiring happens in there again or something. I can't explain it any different.

I'm sure that this integration test is not the first integration test being run and still the asynchronous bit seems to be in place.

Well, test is green, it works...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!