AndroidStudio/Gradle with powermock

后端 未结 7 1567
小鲜肉
小鲜肉 2020-12-29 01:28

I couldn\'t find any info on how to setup powermock with Android Studio/Gradle. Everything I\'ve tried resulted in build exceptions.

Could anybody show a correct way

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 01:51

    In the build script, add the following:

    sourceSets {
        unitTest {
            java.srcDir file('*your test directory*') //for example: tests/java
        }
    }
    
    android {
        sourceSets {
            instrumentTest.setRoot('*your root test directory*') //for example: tests
        }
    }
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        testCompile 'junit:junit:4.11'
        testCompile 'org.powermock:powermock-mockito-release-full:1.4.9'
    }
    

    Then, do gradle unitTest from the command line.

    Hope that works. If it doesn't, post the output of the command line.

提交回复
热议问题