Running a specific instrumentation unit test with Gradle

后端 未结 8 783
既然无缘
既然无缘 2020-11-30 04:27

Is there a way to run a specific Android instrumentation unit test using Gradle? I\'ve tried

gradle -Dtest.single=UnitTestName connectedInstrumentTest


        
相关标签:
8条回答
  • 2020-11-30 05:19

    Since Android gradle plugin 1.1.0-rc1, one can run single test class using --tests flag by executing:

    ./gradlew app:testDebug --tests=com.example.MyTest
    

    See http://tools.android.com/tech-docs/unit-testing-support#TOC-Running-from-Gradle

    0 讨论(0)
  • 2020-11-30 05:23

    You gotta check this out.

    https://github.com/JCAndKSolutions/android-unit-test

    I made an issue in this github repository, and this guy solved my problem and upload to maven, so in my build.gradle file I use this plugin.

    Instructions are written in his repository. you can easily follow it.

    After using this android-unit-test plugin, I can use like

    ../gradlew -Dtest.single=SomeTest test 
    

    or

    ../gradlew -Dtest.single=SomeTest clean check
    

    Now it's working and I could only run the specific tests I want to

    0 讨论(0)
提交回复
热议问题