运行 针对独立/云服务器的 SpringTests / SpringBootTests

Running SpringTests / SpringBootTests against standalone / cloud server

我们目前有一个设置,我们有很多测试 运行ning 作为 "SpringBootTests"。现在,当我们开发云应用程序时,我们想要测试实际场景,并且需要 运行 针对 spring 应用程序的云部署进行这些测试。我尝试了各种方法,例如在 config.yml 中添加 server.url 或 server.host,删除 SpringBootTest 应用程序等,但没有任何效果。

不幸的是,我们的 spring 亲正在休假一段时间,所以我在 SO 和 google 上搜索了很长时间,但没有找到任何答案。这就是我现在在这里问的原因。

注解是这样的: @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, classes = Core.class)

config.yml 服务器部分:

server:
  port: 8080
  contextPath: /

基本上我需要的只是告诉测试不要启动 spring 本身,而是使用云,所以我需要一种方法来为测试提供端口和 url。

有什么想法吗?

感谢您的意见和问候, 凯

好的,似乎在测试代码中有一个硬编码的 "localhost"(一些基础测试 class,它初始化所有内容)。改变这个解决了这个问题。似乎一直都是 spring 配置问题,所以我在这里被误导了。