2016-09-11 13 views
12

Gradle ma blok konfiguracji testowejGradle - równoważny badanego {} bloku konfiguracji android

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) 
    } 
} 

którym można ustawić wszystkie rodzaje konfiguracji testowej (I jestem głównie zainteresowany wielkością sterty). Czy jest coś podobnego do projektów Androida?

Odpowiedz

8

Istnieje możliwość dodania ich. Wtyczka Android Gradle ma parametr testOptions, który ma parametr unitTests, który ma opcję all.

Więc jeśli piszesz:

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

testy zostaną wykonane z określonymi parametrami.

+0

Właśnie tego szukałem. Już go używałem, ale całkowicie go przeoczyłem, gdy zaczynałem wychodzić z błędów pamięci podczas uruchamiania testów. Próbowałem jeszcze kilka parametrów znalezionych tutaj https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html i wydawało się, że działają –

Powiązane problemy