Java 在Eclipse中使用POM跳过mvn集成测试

Java 在Eclipse中使用POM跳过mvn集成测试,java,eclipse,maven,integration-testing,Java,Eclipse,Maven,Integration Testing,我已经创建了POM中定义的测试和集成测试(IT)以及从命令行运行的类名;我现在希望他们从Eclipse运行它们。以下是骨架: 测试: 运行时使用: 清洁试验 以及集成测试: package org.xmlcml.it; import org.junit.Test; import junit.framework.Assert; public class SimpleIT { @Test public void integrationTest() { Ass

我已经创建了POM中定义的测试和集成测试(IT)以及从命令行运行的类名;我现在希望他们从Eclipse运行它们。以下是骨架:

测试:

运行时使用:

清洁试验
以及集成测试:

package org.xmlcml.it;

import org.junit.Test;
import junit.framework.Assert;

public class SimpleIT {

    @Test
    public void integrationTest() {
        Assert.assertTrue("integrationTest", true);
        System.out.println("RAN integrationTest");
    }
}

mvn清洁集成测试

我的POM是:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <properties>
       <junit.version>4.8.2</junit.version>

       <!-- if this is uncommented the tests are all skipped
        <skipTests>true</skipTests>
        -->
        <!-- 
        <skipITs>true</skipITs>
        -->
    </properties>

    <groupId>org.contentmine</groupId>
    <artifactId>simple</artifactId>
    <version>0.1-SNAPSHOT</version>
    <name>Simple</name>
    <description>Test integration test</description>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
        </dependency>
    </dependencies>

<!-- http://maven.apache.org/surefire/maven-failsafe-plugin/usage.html -->    
    <build>
       <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.21.0</version>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
       </plugins>
    </build>

</project>

4.0.0
4.8.2
org.contentmine


作为指导,但在打开和关闭测试的多种方式上仍然存在问题(
@Test
*Test.java
,method
public void testFoo()
${skipTests}
),一些SO答案被标记为过时。我不清楚哪个优先-是否有最新的备忘单?

您询问如何打开和关闭测试,但您的pom表明您知道如果取消注释这些属性,您知道默认情况下不会运行测试。您是说这些行在eclipse中不适用,还是说这是一个已解决的问题?默认情况下,这些行不适用。另外,如果可能的话,我不想编辑POM,因为完整的测试版本有被分发的危险。Eclipse中有一个简单的开关吗?我没有下载4.5.2进行测试,但是有了4.7.2(氧气),您可以向构建配置中添加参数。我将使用full-Dmaven.test.skip=true(因此参数名应该是maven.test.skip,值应该是true)。很抱歉,我知道这可能没有完全的帮助,但如果没有相同的版本,我无法验证这是否适用于您。您也可能有幸设置了特定的配置文件:(虽然它提到配置文件不起作用,但有一个关于如何正确设置的示例)。这可能会给你一个“简单”的开发与生产主题,你正在寻找。我会升级,让你知道它是否工作。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <properties>
       <junit.version>4.8.2</junit.version>

       <!-- if this is uncommented the tests are all skipped
        <skipTests>true</skipTests>
        -->
        <!-- 
        <skipITs>true</skipITs>
        -->
    </properties>

    <groupId>org.contentmine</groupId>
    <artifactId>simple</artifactId>
    <version>0.1-SNAPSHOT</version>
    <name>Simple</name>
    <description>Test integration test</description>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
        </dependency>
    </dependencies>

<!-- http://maven.apache.org/surefire/maven-failsafe-plugin/usage.html -->    
    <build>
       <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.21.0</version>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
       </plugins>
    </build>

</project>