2016-09-11 13 views
12

Gradle için deney {} yapılandırma bloğun eşdeğer bir test konfigürasyonu her türlü ayarlayabilir test konfigürasyonu blokGradle - robot

https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html

`

apply plugin: 'java' // adds 'test' task 

test { 
    // enable TestNG support (default is JUnit) 
    useTestNG() 

    // set a system property for the test JVM(s) 
    systemProperty 'some.prop', 'value' 

    // explicitly include or exclude tests 
    include 'org/foo/**' 
    exclude 'org/boo/**' 

    // show standard out and standard error of the test JVM(s) on the console 
    testLogging.showStandardStreams = true 

    // set heap size for the test JVM(s) 
    minHeapSize = "128m" 
    maxHeapSize = "512m" 

    // set JVM arguments for the test JVM(s) 
    jvmArgs '-XX:MaxPermSize=256m' 

    // listen to events in the test execution lifecycle 
    beforeTest { descriptor -> 
    logger.lifecycle("Running test: " + descriptor) 
    } 

    // listen to standard out and standard error of the test JVM(s) 
    onOutput { descriptor, event -> 
    logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message) 
    } 
} 

(I var çoğunlukla yığın boyutu ile ilgileniyorum). Android projeleri için benzer bir şey var mı?

cevap

8

Ekleme olanağı vardır. Android Gradle eklentisi, all seçeneğine sahip unitTests parametresine sahip testOptions parametresine sahiptir.

Yazdığınız Yani eğer:

android { 
    testOptions { 
     unitTests.all { 
      ///apply test parameters 
     } 
    } 
} 

testler belirtilen parametreler ile çalıştırılacaktır.

+0

Bu yüzden aradığım şey teşekkürler. Zaten kullanıyordum ama testlerimi çalıştırırken hafıza hatalarından çıkmaya başladığımda bunu çok özledim. Https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html adresinde bulunan parametrelerin birkaçını daha denedim ve işe yaradı –