简体   繁体   English

Spring 启动 docker 应用程序端到端测试与 chrome 驱动程序

[英]Spring boot docker application end-to-end Testing with chrome driver

I already have Unit and Integration tests with maven but I'm trying to move end-to-end testing with angular(frontend) to maven so I can have every layer of the testing pyramid connected within the same maven build but i'm having trouble doing so.我已经使用 maven 进行了单元和集成测试,但我正在尝试将使用 angular(前端)的端到端测试移动到 maven 所以我可以将测试金字塔的每一层都连接在同一个 Z402C5D9AF6B43711EAZ070BEE 中麻烦这样做。

My spring boot application has some dependencies like postgres and keycloak.我的 spring 引导应用程序具有一些依赖项,例如 postgres 和 keycloak。 I was trying to "mock" does dependencies (in unit and integration tests i use postgres with testcontainers) so i can have an isolated environment without depending on external services are running or not.我试图“模拟”依赖项(在单元和集成测试中,我使用带有 testcontainers 的 postgres),所以我可以拥有一个独立的环境,而不依赖于外部服务是否运行。

I managed to open chrome and do some clicks with selenium and chrome driver but all of this is running on my local database and frontend application which i need to have it up and running.我设法打开 chrome 并使用 selenium 和 chrome 驱动程序进行了一些点击,但所有这些都在我的本地数据库和前端应用程序上运行,我需要启动并运行它。 I want something that i can integrate with jenkins later on so i need something to work isolated.我想要一些我可以稍后与 jenkins 集成的东西,所以我需要一些东西来隔离工作。

I searched on the internet but i could't find any scenario like this.我在互联网上搜索,但我找不到任何这样的场景。 Anyone could help?任何人都可以帮忙吗?

You can have Jenkins flow as您可以让 Jenkins 流为

+--------------+          +-----------------+       +-----------+
|              |          | Setup Phase     |       |           |
| Trigger Test | -------->| DB setup and    |------>| Run Tests |
|              |          | Any other setup |       |           |
+--------------+          +-----------------+       +-----------+

Your entire end to end tests would be divided into two phases.您的整个端到端测试将分为两个阶段。 In the first phase, you would have to configure all the required services like database, caching layer, test credentials for any third-party services like Keycloak.在第一阶段,您必须为任何第三方服务(如 Keycloak)配置所有必需的服务,如数据库、缓存层、测试凭据。 For example, you need to use a running Postgresql or any other databases as required by the service(s).例如,您需要使用正在运行的 Postgresql 或服务所需的任何其他数据库。 For other third-party services, you can use their sandbox if available otherwise use a different configuration for each test run (also you can have multiple configurations and pick of them based on the other running tests).对于其他第三方服务,如果可用,您可以使用他们的沙箱,否则为每个测试运行使用不同的配置(您也可以有多个配置并根据其他运行的测试选择它们)。 Some of the third party services would require you to have public domain/URL in such cases, you need to configure your services behind public URL.在这种情况下,某些第三方服务会要求您拥有公共域/URL,您需要在公共 URL 后面配置您的服务。

Once you have configured entire systems, then you can start hitting API to gather the response using test scripts.一旦您配置了整个系统,您就可以开始点击 API 以使用测试脚本收集响应。 There could be some time, where API might not provide you the exact data you're looking in, in such cases you can add new APIs to the code or use some other technique to gather the data, like DB query, running some manual/automated scripts using FTP, etc.可能有一段时间,API 可能无法为您提供您正在查看的确切数据,在这种情况下,您可以在代码中添加新的 API 或使用其他技术来收集数据,例如数据库查询,运行一些手册/使用 FTP 等的自动化脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM