使用maven-failsafe-plugin时,应该在哪里存储集成测试? [英] Where should the integration tests be stored when using the maven-failsafe-plugin?

查看:193
本文介绍了使用maven-failsafe-plugin时,应该在哪里存储集成测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否必须将我的集成测试置于 src / test 下,并进行其余的单元测试,并通过之类的模式区分它们* Integr * Test * ITTest ,或者它们可以在 src / it (开发Maven插件并使用 maven-invoker-plugin 时的情况就是这样?

Do I have to place my integration tests under src/test with the rest of my unit tests and just distinguish them by a pattern such as *Integr*Test, *ITTest, or can they be in src/it (as is the case when developing Maven plugins and using the maven-invoker-plugin)?

我在问这是因为,如果单元和集成测试都在同一个地方,它看起来不够干净(即使它们是通过Maven配置文件控制的)。

I'm asking this because, to me it looks not clean enough if both unit and integration tests are in the same place, (even if they were to be controlled via a Maven profile).

推荐答案

第一个maven-failed-plugin默认在另一个生命周期阶段(集成测试)中运行,就像maven-surefire-plugin(test)那样。此外,您可以配置maven-failsafe-plugin,以便在 post-integration-test 测试阶段运行验证目标想检查集成测试是否失败。这可以自由配置。

First maven-fails-plugin runs by default in another life cycle phase (integration-test) as maven-surefire-plugin (test) does. Furthermore you can configurate maven-failsafe-plugin to run verify goal at the post-integration-test test phase if you like to check if integration tests have failed. This can be freely configured.

我想到了一个问题。你有10个模块,现在你想进行集成测试?它们属于哪个模块?所以最好有一个单独的模块,因为它们不属于10个模块。

There is one question coming into my mind. You have 10 modules and now you would like to have integration tests? To which module do they belong? So best is to have a separate module cause they belong to none of the 10 modules.

除了maven-surefire-plugin已经在默认生命周期中配置。是的,补充目标是一个想法,但它会混淆用户在不同的关系中使用相同的插件。因此,关注点的分离在这里很重要。除了整个默认配置...这些插件共享更大的代码库但有差异...

Apart from that maven-surefire-plugin is already configured in default life cycle. Yes a supplemental goal would be an idea, but it would confuse user to use the same plugins in different relationships. So separation of concerns is important here. Apart from the whole default configurations...Those plugins share a larger code base but there are differences...

Tunaki已经提到的是 pre-integration-test ,用于服务器等设置。 integration-test 以及在<$中关闭服务/服务器之类的事情c $ c> post-integration-test 阶段。这在单元测试中永远不会发生。

Also what has already been mentioned by Tunaki is pre-integration-test, for setup things like servers etc. integration-test and things like shutting down services/servers in post-integration-test phase. This will never happen in unit tests.

使用单独的模块使得设置IT通常更简单,这意味着具有与单元测试不同的依赖关系(类路径)。例如像Arquillian.org这样的东西,它从未在单元测试中使用过。这不能在一个单独的模块中处理...这里也是一个很好的问题分离..

Using a separate module makes it usually simpler to setup the IT's which means having different dependencies (classpath) than for the unit tests. For example things like Arquillian.org which is never using in unit tests. This can't be handled in a single module...also a good things is separation of concerns here..

此外,默认情况下集成测试无法并行化测试可以按照定义,否则他们不是单元测试。

Furthermore integration tests could not be parallized by default whereas unit tests can be by definition otherwise they not unit tests.

那么文件夹布局呢?在集成测试模块中,您只需使用 src / test / java 文件夹,这意味着您不需要补充配置等(例如,通过build-helper-maven-插件等)这使得它更容易,并遵循更多的约定优于配置范例。

So what about folder layout? In the integration test module you can simply use the src/test/java folder which means you don't need supplemental configuration etc. (for example via build-helper-maven-plugin etc.) which makes it easier and follows more the convention over configuration paradigm.

不要忘记你可以更好地控制你的构建(CI)中正在运行的内容。 。

And not to forget you can better control what is running in your build (CI)..

另一个重要提示。通常,集成测试通常与基础架构相关,因此有时可以忽略那些可以通过使用检查 maven-failsafe-plugin的目标来简单处理的故障。

And another important hint. Usually integration tests are often related to infrastructure so it might sometimes useful to ignore failures there which can simply handle by using check goal of maven-failsafe-plugin....

可以找到IT模块的示例这里

An example for an IT module can be found here.

这篇关于使用maven-failsafe-plugin时,应该在哪里存储集成测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆