Maven 2多模块pom
我最近开始将我的项目从 ant 迁移到 Maven。我的应用程序中有两个模块,我可以使用 Maven 构建它们。
现在我有一个自动化测试项目,它使用 Web Driver 来测试 UI 功能。我试图使用maven 构建两个模块wars 并将它们部署到tomcat 上。然后针对它们运行自动化测试,如果自动化测试通过,则通过构建。我已经像这样配置了我的 pom(仅提到重要部分):
<packaging>pom</packaging>
<modules>
<module>../module1</module>
<module>../module2</module>
</modules>
现在两个项目都已构建和部署,但它不运行自动化测试。我想到的原因是封装类型是POM。但如果我将其更改为战争,它就会开始抛出错误。
我可以考虑创建第三个 pom 来实现自动化,并创建父 pom 将其也包含为模块。但我在想这是否是一个正确的方法。这应该是一个很常见的场景,maven 应该直接支持它。
I have recently started migrating my project from ant to maven. I have two module in my application which I am able to build using maven.
Now I have automated tests project which use Web Driver for testing UI functionality. What I am trying to do using maven is to build both module wars and deploy them on to tomcat. Then run automation tests against them and pass the build if automation test passes. I have configured my pom like this(just mentioning important part):
<packaging>pom</packaging>
<modules>
<module>../module1</module>
<module>../module2</module>
</modules>
Now Both the projects get build and deploy but It doesn't run automation tests. The reason I thought is that packaging type is POM. But If I change it to war it starts throwing error.
I can think of creating third pom for automation and parent pom to include that as module also. But I am thinking whether this is a right way. It should be a very common scenario and maven should be supporting it directly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这绝对是可行的(而且我已经做过很多次了)。但我不确定您当前的项目结构(特别是测试所在的位置)。
以下是我建议的结构:
有关 pom 设置的详细信息,请查看 功能测试Maven、Cargo 和 Selenium,它包含所需的所有详细信息。
This is definitely doable (and I've done it numerous time). But I'm not sure to understand your current project structure (especially, where the tests are located).
Here is the structure I suggest:
And for the details of the pom setup, have a look at Functional testing with Maven, Cargo and Selenium, it contains all the details required.
我不认为带有共享集成测试模块的 2 个 war 模块是非常常见的场景。
但是,您可以使用 Hudson 来实现此功能。
您可能需要使用配置文件来激活集成测试,或更多特别是为了防止在第一个作业期间执行集成测试。
今年早些时候,我在大约一个小时内设置了一个基本的 Hudson 服务器。
Hudson 直接支持 Maven 构建,还为您的项目提供了一个位置 Maven 站点,包括所有质量报告等。
您还可以将 Hudson 配置为“监视”您的 SCM,并在识别到提交时启动构建。
I don't think that 2 war modules with a shared integration test module is a very common scenario.
However, you could get this working with Hudson.
You may want to use profiles to activate integration testing, or more specifically to prevent integration tests from being executed during the first job.
I have earlier this year set-up a basic Hudson server in roughly an hour.
Hudson has direct support for maven builds and also provides a location for your projects maven site, including all of the quality reports etc.
You can also configure Hudson to "watch" your SCM, and initiate a build when it identifies a commit.
“我可以考虑创建第三个 pom”
你只有两个 POM 吗?每个项目/模块都需要自己的 POM。
请在此处查看有关使用 Maven 进行集成测试的更多信息:http://docs。 codehaus.org/display/MAVENUSER/Maven+and+Integration+Testing
编辑:
我不明白你的项目布局到底是什么样的。但我想它应该看起来像这样:
文件结构
/myWebApp/pom.xml
通过此设置,
/myWebApp/mvn deploy
将执行以下步骤:/myWebApp/myWebApp-web/pom.xml
中配置)这应该可以满足您的要求。
"I can think of creating third pom"
Do you have only two POMs? Each project/module needs its own POM.
Look here for more information on integration tests with maven: http://docs.codehaus.org/display/MAVENUSER/Maven+and+Integration+Testing
Edit:
I don't understand exactly what your project layout looks like. But I guess it should look somehow like this:
File structure
/myWebApp/pom.xml
With this setup,
/myWebApp/mvn deploy
will execute the following steps:/myWebApp/myWebApp-web/pom.xml
)This should do what you want.