AndroidStudio2.0以上进行单元测试详解

来源:互联网 发布:做广告牌的软件 编辑:程序博客网 时间:2024/06/05 13:23

AndroidStudio2.0以上版本在单元测试这块相对以前有些改变。
一、介绍
1,点击 Build Variants,Test Artifact没有
Build Variants的位置如下
这里写图片描述
如果没有找到Build Variants,可以通过View–>Tool Windows–>Build Variants获取出来。
把Test Artifact调出来的方法是:
File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle -> Experimental
将Enable all test artifacts (Unit Test and Instrumentation Test) in Android projects取消勾选,之后我们熟悉的Test Artifact就出现了
二、测试
作为测试的两个包,如下图所示
这里写图片描述
androidTest目录下为编写Android测试用例使用,需要真机或者虚拟机下测试,test目录下未编写Java测试用例使用,在本地环境下测试,不用真机,电脑上就能直接运行。

原创粉丝点击