How can I configure a build.gradle
in an Android project to run all my unit tests before each debug or release build? I know that I can set tasks dependencies with dependsOn
, but how can I specify it for the unit test task? I'd like to do this for each (Android and plain Java) module of my project, is it possible?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- How to replace file-access references for a module
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
Go to Run/Debug Configurations, and select your application configuration. At the bottom of the right panel, under Before launch:, click the + button, and select Run another configuration. There, choose the configuration for running your tests.
In before launch set your test case command to run them.
else for pre gradle task refer here
Do you have a special task to run only unit tests? Or you are free to run it as simple
test
(or more generallytestDebug
andtestRelease
)? Let's say, you want to runtestDebug
ortestRelease
every time you callassembleDebug
orassembleRelease
task. Then you can, as you've noted, usedependsOn
task property. For example this way:This configuration must be added to every build.gradle script (in every module of the project), where you need it. If you have a number of test tasksm you can set task dependencies this way:
Sure, you can try to set this dependencies in the root the root build.gradle script, by using
allprojects
orsubprojects
(you can read about it here), but you have to applyandroid
plugin in the root script too, otherwise tasks won't be found.