版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/liuxingyuzaixian/article/details/82719269
一、在需要进行Jnit测试的Module的Gradle中引入测试框架
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
在dependencies加入。实际上Android Studio、Idea已经默认给我们配置好了
二、选择要测试类中的方法,在类名上右键选择Go To > Test > Create New Test...
依次填写完Class Name、Destination package,勾选setUp(该方法内部完成实例化对象的操作),勾选你要测试的方法
并选择路径
在TimeUtilsTest上右键,选择Run TimeUtilsTest
结果为
其他使用方法未完待续。。。