如何配置maven安装以跳过eclipse中的测试?

发布于 2024-12-28 04:54:42 字数 67 浏览 3 评论 0原文

是否可以在 Eclipse 中配置 run as maven install 来跳过单元测试?如果可以的话,该怎么办呢?

Is it possible to configure run as maven install in eclipse to skip unit tests? If so, how can it be done?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

守护在此方 2025-01-04 04:54:42
  1. 确保为您的项目配置了 Maven
  2. 右键单击​​您的项目
  3. 转到“运行方式”
  4. 选择“运行配置”
  5. 在左侧栏中,右键单击“Maven 构建”并选择“新建”
  6. 选择基本目录(项目)您想要从
  7. “安装”开始构建,并在“目标”字段中写入您想要的任何其他目标
  8. 单击“跳过测试”单选按钮
  9. 单击运行!
  1. Ensure Maven is configured for your project
  2. Right-click on your project
  3. Go to 'Run As'
  4. Select 'Run Configurations'
  5. In the left-hand column, right-click 'Maven Build' and select 'New'
  6. Select the base directory (the project) you want to build from
  7. Write 'install' and any other goals you want in the 'Goals' field
  8. Click the 'Skip Tests' radio button
  9. Click Run!
请持续率性 2025-01-04 04:54:42

根据 maven 文档 你可以这样写你的pom.xml:

<project>


[...]
<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12</version>
    <configuration>
      <skipTests>true</skipTests>
    </configuration>
  </plugin>
</plugins>

accordig to maven's document you can write this in you pom.xml:

<project>


[...]
<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12</version>
    <configuration>
      <skipTests>true</skipTests>
    </configuration>
  </plugin>
</plugins>

撩人痒 2025-01-04 04:54:42

这取决于您使用的 Maven 测试插件。您可以尝试将参数 -Dmaven.test.skip=true 添加到构建配置中。

It depends on maven test plugin that you use. You can try add parameter -Dmaven.test.skip=true to your build configuration.

久隐师 2025-01-04 04:54:42

您可以将 maven.test.skip 属性放入 pom 的配置文件中。然后你在eclipse中maven的项目属性中激活这个配置文件。

You can put the property maven.test.skip in a profile in your pom. And then you activate this profile in eclipse in the project properties of maven in eclipse.

烂人 2025-01-04 04:54:42

在运行配置中,有一个 Maven 构建类型的运行配置。此时,您可以设置标准 Maven skipTests 参数。

At the Run configurations there is a Maven Build type of Run configuration. At that you could set up the standard Maven skipTests parameter.

ぃ弥猫深巷。 2025-01-04 04:54:42

将其放入我的 Pom.xml 中会关闭我的测试 - 但在 Maven 构建时,而不是在 Maven 安装时。

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.18.1</version>
        <configuration>
            <excludes>
               <exclude>**/*Test.java</exclude>
            </excludes>
        </configuration>
</plugin>

Putting this in my Pom.xml turned off the tests for me - but at maven build, not at maven install.

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.18.1</version>
        <configuration>
            <excludes>
               <exclude>**/*Test.java</exclude>
            </excludes>
        </configuration>
</plugin>
请止步禁区 2025-01-04 04:54:42
  • 进入您的根项目并右键单击 右键单击打开的菜单的屏幕截图
  • 必须运行为并单击运行配置
  • 在左侧,转到 Maven Build,右键单击并创建新的
  • 选择您的基础项目,给出目标中的名字文本字段,添加
    您的构建类型并添加参数 -DskipTests=true
    -Dmaven.test.failure.ignore=true构建参数窗口的屏幕截图

跳过测试的 Maven 构建目标的示例是: clean install -DskipTests=true -Dmaven.test.failure.ignore=true。

  • Got to your root project and right click screenshot of the menu that opens at right click
  • Got to run as and click on run configurations
  • On the left, go to Maven Build, right click and create new
  • Choose your base project, give a name in the goals textfield, add
    your kind of build and add the parameters -DskipTests=true
    -Dmaven.test.failure.ignore=truescreenshot of the build parameters window

An example of a maven build goal to skip tests is: clean install -DskipTests=true -Dmaven.test.failure.ignore=true.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文