如何Maven的pom.xml的标识非标准项目结构TestNG的测试案例? [英] How maven pom.xml identifies the testng test cases in a non-standard project structure?

查看:147
本文介绍了如何Maven的pom.xml的标识非标准项目结构TestNG的测试案例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是完全新的Maven和TestNG的。我使用Maven作为构建工具,和TestNG作为我的测试框架。我没有按照标准的Maven项目结构。现在,我希望我的的pom.xml 在我的项目执行测试用例。现在的问题是,的pom.xml 如何知道是什么测试用例考虑执行?


解决方案

如果您记住这一个地方,你需要设置的Maven的万无一失的 testClassesDirectory 参数-plugin配置:

 <项目>
  [...]
  <建立>
    <&插件GT;
      <&插件GT;
        <&的groupId GT; org.apache.maven.plugins< /的groupId>
        <&的artifactId GT; Maven的万无一失,插件< / artifactId的>
        <&版GT; 2.17< /版本>
        <结构>
          < testClassesDirectory>路径/要/编译测试类< / testClassesDirectory>
        < /结构>
      < /插件>
    < /插件>
  < /构建>
  [...]
< /项目>

所有这一切都在的Maven Surefire插件文件

I am completely new to maven and testng. I am using maven as build tool, and testng as my testing framework. I am not following the standard maven project structure. Now I want my pom.xml to execute the test cases in my project. The question is, how pom.xml knows what are the test cases to consider for execution?

解决方案

If you keep this in a single place you need to set the testClassesDirectory argument of the maven-surefire-plugin configuration:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.17</version>
        <configuration>
          <testClassesDirectory>path/to/compiled test classes</testClassesDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

All of this is well documented in the Maven Surefire Plugin Documentation

这篇关于如何Maven的pom.xml的标识非标准项目结构TestNG的测试案例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆