Can you get Spring Boot JUnit tests to use the same server?

一世执手 提交于 2019-12-24 07:16:09

问题


I have some Spring Boot JUnit tests that require a somewhat lengthy server start up (I'm loading a complex domain in JPA). I've put them into a test suite, but each test kicks off a new server start up.

Is it possible to set them up in such a way that the server is only started once and each test is loaded onto it and run as if the server were started by the test itself?


回答1:


Okay, so the solution here is actually built in to Spring testing. That is, it caches ApplicationContexts for tests, as described here, as long as the various things like properties are the same.

Ironically, I screwed this up by trying to speed up the tests by using test properties to limit what was loaded.



来源:https://stackoverflow.com/questions/42839765/can-you-get-spring-boot-junit-tests-to-use-the-same-server

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