简体   繁体   English

如何远程执行测试代码(maven/java/testNG/selenium)?

[英]How to execute test code (maven/java/testNG/selenium) remotely?

I running locally a Maven/Selenium/Java/TestNG test project for a bit, and I wish I could push it to Docker/Kube so that it will be executed remotely, without using my machine's power and also in order to be able to be used "without" me.我在本地运行了一个 Maven/Selenium/Java/TestNG 测试项目,我希望我可以将它推送到 Docker/Kube,这样它就可以远程执行,而无需使用我的机器的电源,也为了能够使用“没有”我。

My concern is that every time I look for examples or documentation about it, I can only find explanation about running the driver interactions remotely using Selenium Grid or similar.我担心的是,每次我查找有关它的示例或文档时,我只能找到有关使用 Selenium Grid 或类似的远程运行驱动程序交互的解释。 But never about running the test code by itself remotely.但永远不要远程运行测试代码 Any tutorials or examples about it?关于它的任何教程或示例?

I plan on using Browserstack (or a similar solution with remote driver) for driver interactions, and I already run a local Allure server for reporting, so I only need to containerise the test code, and I wonder if anyone of you has already done it and how.我计划使用 Browserstack(或具有远程驱动程序的类似解决方案)进行驱动程序交互,并且我已经运行了本地 Allure 服务器进行报告,所以我只需要将测试代码容器化,不知道你们中是否有人已经这样做了如何。 Any suggestion is welcome:)欢迎任何建议:)

You can do that by multiple approches, but first you need to create a dockerfile您可以通过多种方式做到这一点,但首先您需要创建一个 dockerfile

Using a specific mvn plugin spotify and that needs to be configured in your pom file.使用特定的 mvn 插件 spotify 并且需要在您的 pom 文件中进行配置。

Or just by just using docker commands, https://docs.docker.com/engine/reference/commandline/build/#:~:text=The%20docker%20build%20command%20builds%20Docker%20images%20from,instruction%20to%20reference%20a%20file%20in%20the%20context . Or just by just using docker commands, https://docs.docker.com/engine/reference/commandline/build/#:~:text=The%20docker%20build%20command%20builds%20Docker%20images%20from,instruction% 20to%20reference%20a%20file%20in%20the%20context

To run selenium you have to see the command line option.要运行 selenium 您必须查看命令行选项。 You can directly run using testng as per the below discussion:您可以按照以下讨论直接使用 testng 运行:

How to run TestNG from command line 如何从命令行运行 TestNG

But as you are already using maven for build management, you can use surefire-plugin and run mvn test to execute the test.但是由于您已经使用 maven 进行构建管理,您可以使用 surefire-plugin 并运行 mvn test 来执行测试。 see the discussion at:见讨论:

How to run testng.xml from Maven command line 如何从 Maven 命令行运行 testng.xml

When ever you integrate tests or any other tools in CI/CD or any other such tools see for command line options.当您在 CI/CD 或任何其他此类工具中集成测试或任何其他工具时,请参阅命令行选项。 See how you can execute test from command line查看如何从命令行执行测试

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

相关问题 如何在Eclipse中以TestNG的形式执行Selenium Webdriver测试 - How to execute Selenium Webdriver test as TestNG in eclipse Selenium WebDriver:如何在失败的测试用例中在testNG中执行完整的测试 - Selenium WebDriver: How to execute complete Test in testNG for a failed test case 如何在Java中执行Selenium测试 - How to execute a Selenium test in Java 如何使用Java通过Selenium RC和TestNG顺序运行/执行方法 - How to run/execute methods sequentially by Selenium RC and TestNG using Java How to run maven selenium project in docker (Maven + Selenium + java + TestNg + docker) - How to run maven selenium project in docker (Maven + Selenium + java + TestNg + docker) Testng和Maven,Java Selenium的魅力报告问题 - Allure reporting issue with testng and maven, java selenium 无法执行硒测试代码(FileNotFoundException) - Unable to execute selenium testng code ( FileNotFoundException) 使用Java自动执行Selenium TestNG脚本 - Automatically execute Selenium TestNG script using java 基于环境变量值跳过测试用例(Java maven testNG Selenium自动化) - Skipping test cases based on environment variable value (Java maven testNG Selenium automation) 如何通过main()和TestNG在IDE中编写Selenium Java Application代码 - How to write Selenium Java Application code in IDE through main() and TestNG
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM