简体   繁体   English

Maven pom.xml如何在非标准项目结构中识别出Testng测试用例?

[英]How maven pom.xml identifies the testng test cases in a non-standard project structure?

I am completely new to maven and testng. 我对Maven和Testng完全陌生。 I am using maven as build tool, and testng as my testing framework. 我正在使用maven作为构建工具,并使用testng作为我的测试框架。 I am not following the standard maven project structure. 我没有遵循标准的Maven项目结构。 Now I want my pom.xml to execute the test cases in my project. 现在,我希望pom.xml在项目中执行测试用例。 The question is, how pom.xml knows what are the test cases to consider for execution? 问题是, pom.xml如何知道要考虑执行哪些测试用例?

If you keep this in a single place you need to set the testClassesDirectory argument of the maven-surefire-plugin configuration: 如果将其放在一个位置,则需要设置maven-surefire-plugin配置的testClassesDirectory参数:

<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 Surefire插件文档中有详细记录

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

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