2016-10-07 95 views
0

運行我testing.xml作爲TestNG的滿足其正常運行,但運行的gradle 測試任務時,不執行測試如何通過gradle測試任務執行測試方法?

testing.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> 
<suite guice-stage="DEVELOPMENT" name="Default suite"> 
    <test verbose="2" name="test"> 
    <classes> 
     <class name="com.example.EmpBusinessLogicTest"/> 
    </classes> 
    </test> <!-- Default test --> 
</suite> <!-- Default suite --> 

構建。 gradle

buildscript { ext { springBootVersion ='1.4.1.RELEASE' } 庫{ mavenCentral() } 依賴{ 類路徑( 「org.springframework.boot:彈簧引導gradle這個-插件:$ {springBootVersion}」) }}

apply plugin: 'java' 
apply plugin: 'eclipse' 
apply plugin: 'spring-boot' 

jar { 
    baseName = 'demo' 
    version = '0.0.1-SNAPSHOT' 
} 
sourceCompatibility = 1.8 
targetCompatibility = 1.8 


repositories { 
    mavenCentral() 
} 


dependencies { 
    compile('org.springframework.boot:spring-boot-starter-web') 
    testCompile('org.springframework.boot:spring-boot-starter-test') 
    compile('org.testng:testng:6.9.10') 

} 

test { 
    useTestNG() 
    {   
     suites 'src/main/resources/testing.xml' 

    } 
} 

能任何人都幫我執行gradle測試任務?

回答

1

至於選項,您可以直接生成在測試任務gradle這個XML,它在我們的項目中工作正常

useTestNG() { 
    suiteXmlBuilder().suite(name: 'Default suite') { 
     test(name : 'test') { 
      classes('') { 
       'class'(name: 'com.example.EmpBusinessLogicTest') 
      } 
     } 
    } 
} 

要如執行該測試任務與詹金斯,你需要傳遞系統屬性:

systemProperties System.getProperties() 
systemProperty 'user.dir', project.projectDir 
相關問題