2016-09-11 11 views
12

Gradle के लिए परीक्षण {} विन्यास ब्लॉक के बराबर परीक्षण विन्यास ब्लॉकGradle - एंड्रॉयड

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

एक परीक्षण विन्यास के सभी प्रकार जहां निर्धारित कर सकते हैं (मैं है ज्यादातर ढेर आकार में रुचि रखते हैं)। क्या एंड्रॉइड परियोजनाओं के लिए कुछ समान है?

उत्तर

8

उन्हें जोड़ने की संभावना है। एंड्रॉइड ग्रैडल प्लगइन में पैरामीटर testOptions है, जिसमें पैरामीटर unitTests है, जिसमें विकल्प all है।

तो अगर आप लिखें:

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

परीक्षण निर्दिष्ट मापदंडों के साथ निष्पादित किया जाएगा।

+0

यही वह है जिसे मैं धन्यवाद चाहता था। मैं पहले से ही इसका उपयोग कर रहा था, लेकिन जब मैंने अपने परीक्षण चलाते समय स्मृति त्रुटियों से बाहर निकलना शुरू कर दिया तो मुझे पूरी तरह याद आया। मैंने https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html यहां पाए गए कुछ और पैरामीटरों की कोशिश की और वे काम करना प्रतीत हुए –

संबंधित मुद्दे