How to run JUnit tests in an Android runtime?

问题: The official JDK and the Android runtimes are fairly similar but support different sets of classes. For example, the java.awt package is unavailable on Android, and the and...

问题:

The official JDK and the Android runtimes are fairly similar but support different sets of classes. For example, the java.awt package is unavailable on Android, and the android packages are unavailable in the JDK.

In order to write a Java library that functions in both regular Java and Android, it would be desirable to run the JUnit tests inside both VMs. Is there a way to do this, such as using a Maven plugin? Or is there a different approach that's recommended?


回答1:

Unit tests executed on an Android device/emulator - or "Instrumented Unit Tests" as they are called can be developed using Android Studio / Gradle.

I am not sure if and how Instrumented Unit Tests can be performed directly with Maven.

One possible way would be to execute Gradle from within Maven using gradle-maven-plugin.

  • 发表于 2018-07-14 03:15
  • 阅读 ( 312 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除