2016-09-11 3 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) 
    } 
} 

(I을 갖는다 주로 힙 크기에 관심이 있습니다). 거기에 안드로이드 프로젝트에 대한 비슷한가요?

답변

8

추가 할 가능성이 있습니다. Android Gradle Plugin의 매개 변수는 unitTests이고 all 인 매개 변수 testOptions입니다.

당신은 쓰기 그래서 경우 :

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

시험은 지정된 매개 변수와 함께 실행됩니다.

+0

내가 감사의 대상이었습니다. 나는 이미 그것을 사용하고 있었지만 테스트를 실행할 때 메모리 오류가 발생하기 시작했다. 나는 여기에 몇 가지 매개 변수를 추가로 시도 https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html 그리고 그들은 일을하는 것처럼 보였다. –