【问题标题】:Maven eclipse run Test SuiteMaven eclipse 运行测试套件
【发布时间】:2013-12-11 16:46:20
【问题描述】:

这是我正在使用的 maven surefire 插件

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.16</version>
    <configuration>
    <includes>
    <include>runner.TestSuite.java</include>
    </includes>
    <skipTests>true</skipTests>
    </configuration>
</plugin>

这是 testSuite 类

package runner;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

import action.TestLogin;
import action.TestRegister;

@RunWith(Suite.class)
@Suite.SuiteClasses({ TestRegister.class, TestLogin.class })
public class TestSuite {
}

Test Suite 单独运行良好。 但是当我使用 Eclipse 运行 maven-Install 时,我想运行测试套件而不单独运行所有测试用例。但它说

[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ FinalProject ---
[INFO] Tests are skipped.

我也在使用声纳来检查线路覆盖率,这也无法检测到我制作的 testSuite。 我是 Junit TestSuite 的新手,不知道如何使用 maven 和声纳配置它们。

任何链接、参考或线索都会有所帮助。 谢谢。

【问题讨论】:

  • 删除&lt;skipTests&gt;true&lt;/skipTests&gt;这一行,否则测试将无法运行。
  • 感谢您的回复,尽管它没有帮助,因为我希望 maven 运行 TestSuite 类并通过该类运行测试用例。但是,如果按照您的说法删除该行,所有测试用例都将由 maven 运行,这是不可取的。请告诉您是否清楚这个问题。谢谢

标签: unit-testing maven junit sonarqube test-suite


【解决方案1】:

确保在 pom.xml 中指定了 JUnit 依赖项

<dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
</dependency>

这是开始所需的唯一步骤 - 您现在可以在测试源目录中创建测试。

更多信息请访问Maven Surefire Plugin

【讨论】:

  • 感谢您的回复。我有提到的依赖。我想要的是当我运行 maven-install 时测试套件应该运行。但这不会发生,因为 true 这一行;我需要这一行,以便 maven 不会按照它得到的顺序运行测试用例。
猜你喜欢
  • 1970-01-01
  • 2012-12-04
  • 2014-03-25
  • 2013-02-11
  • 1970-01-01
  • 1970-01-01
  • 2011-12-09
  • 2011-07-24
  • 2017-07-12
相关资源
最近更新 更多