简体   繁体   English

Maven 多模块项目是自动化测试(Selenium、Appium、Karate)的良好解决方案吗?

[英]Is Maven Multi-Module project a good solution for automated tests (Selenium, Appium, Karate)?

I have recently created a Java Maven project using Selenium to script web automated tests.我最近创建了一个 Java Maven 项目,使用 Selenium 编写 Z2567A5EC97305EB7AC2CZ98E40 自动化测试脚本。

Now I have to script mobile automated tests, to do so I am going to use Appium.现在我必须编写移动自动化测试脚本,为此我将使用 Appium。

Instead of creating another project quite similar, I wanted to convert my Maven project to a Maven Multi-Module in which a module will contain web automated tests, an other one will contain mobile automated tests and the last one will contain common logics (later another module will be used for API automated tests using Karate).我不想创建另一个非常相似的项目,而是想将我的 Maven 项目转换为 Maven 多模块,其中一个模块将包含 web模块将用于使用空手道的 API 自动化测试)。

I want to know if it is a good idea to use a Maven Multi-Module to do it and if it is, I also want to know if sharing classes in the same project through modules is a good practice.我想知道使用 Maven 多模块是否是一个好主意,如果是,我还想知道通过模块在同一个项目中共享类是否是一个好习惯。

Thanks a lot for helping.非常感谢您的帮助。

Yes.是的。 Multi-module projects are a great way to split up your project into logical components.多模块项目是将项目拆分为逻辑组件的好方法。 But I would consider a few things, First?但我会考虑一些事情,首先? are your tests Junit or TestNG tests, If they are.你的测试是 Junit 还是 TestNG 测试,如果是的话。 I would probably just leave them in your main project under the src/test directory.我可能会把它们留在你的主项目中的 src/test 目录下。

From the sound of it, it doesn't seem like these tests are 'unit' tests exactly, but you can still separate and group them.从它的声音来看,这些测试似乎并不完全是“单元”测试,但您仍然可以将它们分开和分组。 (TestNG has groups and I believe JUnit has something similar) When I have a project with 'unit' and 'integration' tests, I will make unit tests run during the normal build process. (TestNG 有组,我相信 JUnit 有类似的东西)当我有一个带有“单元”和“集成”测试的项目时,我会让单元测试在正常的构建过程中运行。 And make integration tests run using a maven profile.并使用 maven 配置文件运行集成测试。 But if that sounds like too much work, yes, I think multi-modules is a fine way to go.但如果这听起来工作量太大,是的,我认为多模块是 go 的好方法。

And yes, sharing classes between modules is definitely good practice.是的,在模块之间共享类绝对是一个好习惯。 Just as long as you don't have any circular dependencies.只要您没有任何循环依赖项。 That's really the only rule.这真的是唯一的规则。

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

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