2014-10-06 74 views
0

我正在设置一些测试。我有以下的条目在我build.gradle文件:指定组后,未运行Gradle测试任务

integTest { 
    useTestNG() { 
    } 
} 

integTest2 (type: Test){ 
    useTestNG() { 
     include 'Group2' 
    } 
} 

而在我的测试中,我有以下注释:

@Test (groups={"Group2"}) 
public void testMethod() { 
    // Test code here 

} 

当我和gradle这个运行第二个任务(integTest2)只建立我的目录,并没有真正拿起任何测试运行(integTest工作正常,并运行所有的测试,但我希望能够单独运行单独的套件)。

有什么明显的我错过了吗?

回答

1

想出答案。我使用我们公司的内部版本的gradle,它只承认“integTest”是主要任务。因此,作为一种变通方法,我不得不做这样的事情:

def allTestGroups = ['all', 'Group1', 'Group2'] 
def testGroup = project.hasProperty("testGroup") ? project.testGroup : 'all' 


integTest { 
    useTestNG() { 
    includeGroups "${testGroup}" 
    excludeGroups allTestGroups.findAll { it != "${testGroup}" }.collect { "'${it}'" }.join(',') 
    } 
} 
+0

是的好主意,我可以使用类似的方法 – 2016-06-29 14:19:03

0

只是试图改变include 'Group2'includeGroups 'Group2',像这样:

integTest2 (type: Test) { 
    useTestNG { 
     includeGroups 'Group2' 
    } 
} 
+0

谢谢,但仍然没有改变。它只建立目录:( – N3da 2014-10-07 19:15:32

相关问题