如何使用IntelliJ在POM.xml中定义的特定类别上运行Junit测试

时间:2017-09-21 13:35:24

标签: java intellij-idea junit

我想知道是否使用IntelliJ,可以在视觉环境中选择特定的Junit类别运行所有测试。

目前执行:

mvn clean test

您执行快速测试,但如何使用IntelliJ选择快速

pom.xml的片段

  <profiles>
    <profile>
      <id>SlowTest</id>
      <properties>
        <testcase.groups>YOUR.PROJECT.test.categories.Slow</testcase.groups>
      </properties>
    </profile>
    <profile>
      <id>FastTest</id>
      <properties>
        <testcase.groups>YOUR.PROJECT.test.categories.Fast</testcase.groups>
      </properties>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
    </profile>
  </profiles>

非常感谢提前

Juan Antonio

2 个答案:

答案 0 :(得分:1)

您的个人资料正在针对特定类别进行测试。 IntelliJ中的JUnit Run / Debug配置还允许您将JUnit运行集中在特定类别上。

您可以从Run > Edit Configurations访问此配置窗口 这是一个屏幕截图,显示了一个名为SlowTests的已保存的confoguiraiton,它运行所有具有以下类别的测试:com.stackoverflow.surefire.SlowTests

enter image description here

您可以通过单击此窗口左上角的文件图标来保存任何此类配置,然后Run菜单中将显示该配置,您可以even associate a keyboard short cut with it

更多信息in the docs

答案 1 :(得分:0)

如果您使用pom.xml创建了项目,则在“Maven项目”-View中可以激活要激活的配置文件。在那里(生命周期)你也可以为每个模块开始你想要执行的目标。

如何获取此信息:查看 - &gt;工具Windows-&gt; Maven项目