2014-10-06 67 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

相關問題