Maven surefire-plugin跳过测试

时间:2018-07-26 17:59:10

标签: junit4 maven-plugin maven-surefire-plugin

最近在我们的hadoop项目中,我们添加了maven-surefire-plugin用于按类别运行单元测试。 hadoop根pom.xml文件中的相关块如下:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.21.0</version>
      <configuration>
        <groups>${test.groups}</groups>
      </configuration>
      <dependencies>
        <dependency>
          <groupId>org.apache.maven.surefire</groupId>
          <artifactId>surefire-junit47</artifactId>
          <version>2.21.0</version>
        </dependency>
      </dependencies>
    </plugin>

<profile>
  <id>flakies</id>
  <properties>
    <test.groups>org.apache.hadoop.classification.TestJUnitCategory$FlakiesTest</test.groups>
  </properties>
</profile>
<profile>
  <id>stables</id>
  <properties>
    <test.groups>org.apache.hadoop.classification.TestJUnitCategory$StablesTest</test.groups>
  </properties>
</profile>
<profile>
  <id>integrations</id>
  <properties>
    <test.groups>org.apache.hadoop.classification.TestJUnitCategory$IntegrationsTest</test.groups>
  </properties>
</profile>
<profile>
  <id>none</id>
  <properties>
    <test.groups>!org.apache.hadoop.classification.TestJUnitCategory$AllTest</test.groups>
  </properties>
</profile>

按类别调用测试工作正常:mvn -P集成。 但是,此maven-surefire-plugin跳过了老式的单元测试执行:

13:16:35 [INFO] --- maven-antrun-plugin:1.7:run (create-log-dir) @ hadoop-hdfs ---
13:16:35 [INFO] Executing tasks
13:16:35 
13:16:35 main:
13:16:35    [delete] Deleting directory /tmp/tmp.o7flMN8505/src/ghuang/ghuang/hadoop-hdfs-project/hadoop-hdfs/target/test/data
13:16:35     [mkdir] Created dir: /tmp/tmp.o7flMN8505/src/ghuang/ghuang/hadoop-hdfs-project/hadoop-hdfs/target/test/data
13:16:35      [copy] Copying 16 files to /tmp/tmp.o7flMN8505/src/ghuang/ghuang/hadoop-hdfs-project/hadoop-hdfs/target/test-classes/webapps
13:16:35 [INFO] Executed tasks
13:16:35 [INFO] 
13:16:35 [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ hadoop-hdfs ---
13:16:35 [INFO] Nothing to compile - all classes are up to date
13:16:35 [INFO] 
13:16:35 [INFO] --- maven-surefire-plugin:2.20:test (default-test) @ hadoop-hdfs ---
13:16:35 [INFO] Surefire report directory: /tmp/tmp.o7flMN8505/src/ghuang/ghuang/hadoop-hdfs-project/hadoop-hdfs/target/surefire-reports
13:16:35 [INFO] parallel='none', perCoreThreadCount=true, threadCount=0, useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, threadCountMethods=0, parallelOptimized=true
13:16:35 [INFO] 
13:16:35 [INFO] -------------------------------------------------------
13:16:35 [INFO]  T E S T S
13:16:35 [INFO] -------------------------------------------------------
13:26:01 [INFO] 
13:26:01 [INFO] Results:
13:26:01 [INFO] 
13:26:01 [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
13:26:01 [INFO] 
13:26:01 [INFO] 
13:26:01 [INFO] --- maven-antrun-plugin:1.7:run (hdfs-test-bats-driver) @ hadoop-hdfs ---

我还验证了通过删除根pom.xml文件中的surefire-plugin块将使这些测试照常执行。所以我在这里有一些问题:

  1. 为什么在这种情况下跳过测试?

  2. 当我在更改中定义2.21时,我看到报告的surefire插件版本为2.20。我认为这是因为它被父pom覆盖。那么如何使用我的自定义版本呢?

  3. 2.21版是否适合此版本?我看到一些帖子指出版本2.21可能有错误?

非常感谢,

0 个答案:

没有答案