繁体   English   中英

如何在Maven中运行一项IT测试

[英]How to run one single IT test in maven

我有一个项目,其中src / test / java / SingleIT.java中只有一个类

这不是单元测试,而是建立数据库,启动tomcat Embedded的IT测试。

我如何在mvn的帮助下运行它?

编辑:

我需要在pom.xml中进行Maven配置才能运行此文件

profile部分添加到您的pom,以将测试链接到配置文件。

  <profiles>
    <profile>
      <id>IT-Test</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.17</version>
            <configuration>
              <suiteXmlFiles>
                <suiteXmlFile>src/test/java/com/IT-Test.xml</suiteXmlFile>
              </suiteXmlFiles>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

然后以通常的方式定义测试:

就像是:

    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
    <suite name="IT Tests" verbose="1">
         <test name="IT Test">
            <classes>
                <class name="com.xxx.SingleIT"/>
            </classes>
        </test>
    </suite>

现在,每当您要运行测试时-选择配置文件并运行应用程序。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM