2016-03-03 90 views
2

我有“单元测试”和“集成测试”任务定义为gradle这个项目如下:如何的IntelliJ运行gradle这个任务,因为测试

test { 
    include '**/*Test.class' 
} 

task integrationTest(type: Test) { 
    include '**/*IT.class' 
} 

我创建的IntelliJ运行配置来运行所有的单元测试像图片显示:

Run configuration of gradle 'test' task in intelliJ

并没有与任务相同的 'integrationTest':

Run configuration of gradle 'test' task in intelliJ

的IntelliJ“理解”的测试任务,并运行它的图形显示效果,这样的形象:

IntelliJ showing the results of gradle test task

当它运行的“integrationTest”任务同样不会发生。结果显示在文本中,就像我通过命令行运行任务一样。

回答

1

回答我自己的问题... 据我所知,你不能让IntelliJ运行特定任务的测试,而Pattern解决方案不能很好地工作。

所以,唯一的办法,我发现在有效的IntelliJ独立的集成测试与使用JUnit的范畴。

  1. 创建一个接口来表示集成测试。 例如:

    public interface IntegrationTest { 
    } 
    
  2. 你必须标注每一个集成测试类与类注释和创建的接口:

    import org.junit.experimental.categories.Category; 
    import mycompany.mypackage.IntegrationTest; 
    
    @Category(IntegrationTest.class) 
    public class DbfFileProcessorIT { 
        ... 
    } 
    
  3. 创建构建配置与类别过滤: enter image description here

相关问题