如何在构建阶段使用Maven仅运行单元测试而不运行集成测试。

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

How can i run only the unit tests not the integration tests on build phase with maven

问题

我将maven-failsafe-plugin添加到我的项目中以运行集成测试。当我运行test时,只会运行单元测试;当我运行integration-test时,会先运行单元测试,然后再运行集成测试。

到目前为止,这正是我想要的。但是,当我清理并构建项目时,会同时运行单元测试和集成测试,我不太希望这样,因为我并不想在每次构建时都准备集成测试的环境。
我进行项目的清理和构建是为了重新生成一些生成的源代码,而我不想同时运行集成测试。

有没有办法只在有意的情况下运行集成测试,而不是通过任何自动化方式运行?

英文:

I added the maven-failsafe-plugin to my project for runnig integration tests. When i run test only unit tests are running and when i run integration-test first unit tests and then integration tests are running.

It's all what i want so far but when i clean and build the project both unit tests and integration tests are running which i wouldn't prefer because i just don't want to prepare the environment for integration testing on every build.
I clean and build the project for some generated source to regenerate and i don't want to run the integration test meanwhile.

Is there a way that i only run the integration tests on purpose not by any automation?

答案1

得分: 0

我在Maven的clean install命令中添加了-DskipITs标志,以便在执行clean和install操作时不运行集成测试。

我创建了Maven目标integration-testverify,通过failsafe plugin运行和验证集成测试,我已将该插件添加到了我的pom.xml中。

由于我使用NetBeans作为集成开发环境,我通过项目属性的操作选项卡设置了预定义的Maven命令,我可以通过右键点击项目,然后在Maven菜单下选择集成测试子菜单来运行集成测试。

英文:

I added -DskipITs flag clean install command of maven so integration tests are not running when i make a call of clean and install.

And i created maven goals as integration-test and verify to run and verify the integration tests via the failsafe plugin which i added to my pom.xml.

As i'm using netbeans as ide, i set the predefined maven commands via the actions tab of the project properties and i can run the integraion tests via right click to peoject and integration test sub menu under maven menu.

huangapple
  • 本文由 发表于 2020年5月5日 21:40:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/61614589.html
匿名

发表评论

匿名网友

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

确定