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

huangapple go评论73阅读模式
英文:

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

问题

我最近创建了一个使用Selenium来编写Web自动化测试的Java Maven项目。

现在我需要编写移动自动化测试,为此我打算使用Appium。

与其创建另一个相似的项目,我想将我的Maven项目转换为一个Maven多模块项目,其中一个模块将包含Web自动化测试,另一个模块将包含移动自动化测试,最后一个模块将包含通用的逻辑(以后将使用另一个模块来进行使用Karate进行API自动化测试)。

我想知道是否使用Maven多模块项目来实现这个目标是个好主意,如果是的话,我还想知道通过模块在同一个项目中共享类是否是一个好的实践。

非常感谢您的帮助。

英文:

I have recently created a Java Maven project using Selenium to script web automated tests.

Now I have to script mobile automated tests, to do so I am going to use 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).

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.

Thanks a lot for helping.

答案1

得分: 0

是的!多模块项目是将项目拆分为逻辑组件的绝佳方式。但我会考虑一些事情。首先,你的测试是 Junit 还是 TestNG 测试?如果是的话,我可能会将它们留在主项目的 src/test 目录下。

从你的描述听起来,这些测试似乎不完全是“单元”测试,但你仍然可以将它们分开并分组。(TestNG 有分组功能,我相信 JUnit 也有类似的功能)当我有一个同时包含“单元”测试和“集成”测试的项目时,我会让单元测试在正常的构建过程中运行,并使用 Maven 配置文件来运行集成测试。但如果这听起来太麻烦的话,是的,我认为多模块是一个不错的选择。

而且,确实是一个好的实践将类共享在模块之间,只要没有循环依赖就可以。那实际上是唯一的规则。

英文:

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, I would probably just leave them in your main project under the src/test directory.

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. And make integration tests run using a maven profile. But if that sounds like too much work, yes, I think multi-modules is a fine way to 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.

huangapple
  • 本文由 发表于 2020年7月22日 04:57:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/63022985.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定