使用 SpringBoot 后端和 Angular 前端的 E2E 测试
E2E Tests With SpringBoot Backend and Angular Frontend
我正在开发一个包含 2 个模块的应用程序。
- 服务器模块,即SpringBoot。
- ui 在 Angular
我无法 运行 我的应用程序的任何 E2E 测试,因为它没有在测试 运行 之前启动。我在测试 class 中定义了下面的内容,它应该会显示应用程序上下文,但似乎没有。
@ContextConfiguration(classes=Application.class, loader = SpringBootContextLoader.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
当我使用 IDE 中的 运行 按钮正常启动应用程序时,应用程序确实可以正常启动并且 运行 在 localhost:8080
上正确。我不确定为什么当我尝试 运行 测试时应用程序没有出现。
是不是模块不同?
问题不在于模块。有 2 个问题,
- 我使用旧版本的 Chrome 驱动程序进行 运行 测试。
- E2E 测试尝试使用 https 访问应用程序,但我使用的证书是自签名证书。为了克服这个问题,我在我的 chromeoptions 中添加了以下参数。
chromeOptions.addArguments("allow-insecure-localhost");
我正在开发一个包含 2 个模块的应用程序。
- 服务器模块,即SpringBoot。
- ui 在 Angular
我无法 运行 我的应用程序的任何 E2E 测试,因为它没有在测试 运行 之前启动。我在测试 class 中定义了下面的内容,它应该会显示应用程序上下文,但似乎没有。
@ContextConfiguration(classes=Application.class, loader = SpringBootContextLoader.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
当我使用 IDE 中的 运行 按钮正常启动应用程序时,应用程序确实可以正常启动并且 运行 在 localhost:8080
上正确。我不确定为什么当我尝试 运行 测试时应用程序没有出现。
是不是模块不同?
问题不在于模块。有 2 个问题,
- 我使用旧版本的 Chrome 驱动程序进行 运行 测试。
- E2E 测试尝试使用 https 访问应用程序,但我使用的证书是自签名证书。为了克服这个问题,我在我的 chromeoptions 中添加了以下参数。
chromeOptions.addArguments("allow-insecure-localhost");