使用POM跳过Eclipse

时间:2018-04-15 21:47:52

标签: java eclipse maven integration-testing

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

试验:

package org.xmlcml.it;

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

public class SimpleTest {

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

运行: mvn clean test 和集成测试:

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 clean integration-test

我的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>

当我从Eclipse(4.5.2)运行它时,运行IT测试。如何更改POM以便默认跳过它们(如何重新打开它们)? 注意:我用过  http://maven.apache.org/surefire/maven-failsafe-plugin/usage.html
有关指导,但仍有问题,有多种方式可以打开和关闭测试(@Test*Test.java,方法public void testFoo()${skipTests} ...)和一些SO答案被标记为过时。我不清楚哪个优先 - 是否有最新的备忘单?

0 个答案:

没有答案