pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

有沒有辦法只在 Android Gradle 項(xiàng)目中運(yùn)行一組特定

Is there a way to only run a specific set of instrumentation tests in an Android Gradle project?(有沒有辦法只在 Android Gradle 項(xiàng)目中運(yùn)行一組特定的儀器測(cè)試?)
本文介紹了有沒有辦法只在 Android Gradle 項(xiàng)目中運(yùn)行一組特定的儀器測(cè)試?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有一個(gè) Android/Gradle 項(xiàng)目.每當(dāng)我想運(yùn)行測(cè)試時(shí),我都會(huì)運(yùn)行:

./gradlew connectedInstrumentTest

它在我的項(xiàng)目的測(cè)試文件夾下運(yùn)行我的所有測(cè)試.

我的測(cè)試文件夾有幾個(gè)自動(dòng)化測(cè)試以及非自動(dòng)化測(cè)試.我最感興趣的是在沒有慢速自動(dòng)化測(cè)試的情況下運(yùn)行快速的非自動(dòng)化測(cè)試.

有沒有辦法只運(yùn)行一組特定的測(cè)試,例如來自一個(gè)特定的類或類似的東西?我基本上是在詢問任何類型的分離,以便我可以在需要時(shí)選擇只運(yùn)行幾個(gè)測(cè)試.

<小時(shí)>

這里創(chuàng)建了一個(gè)示例項(xiàng)目..p>

編輯 local.properties 以指向您的 Android SDK.

接下來,啟動(dòng)模擬器或?qū)⑹謾C(jī)連接到計(jì)算機(jī).然后您可以使用 ./gradlew connectedInstrumentTest --info 運(yùn)行測(cè)試.這會(huì)運(yùn)行所有測(cè)試.

我無法弄清楚的是如何只在一個(gè)類而不是所有測(cè)試中運(yùn)行測(cè)試.

解決方案

Android Gradle Plugin 1.3.0 起

從 1.3.0 版開始,您可以(終于!)指定 Android Gradle 插件必須傳遞給 InstrumentationTestRunner 的參數(shù).

例如,如果您只想運(yùn)行帶有 @SmallTest 注釋的測(cè)試并忽略其他測(cè)試:

<代碼>android {//....默認(rèn)配置 {//....testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"testInstrumentationRunnerArgument "size", "small"}}

<小時(shí)>

舊的解決方法在插件 1.3.0 之前無法做到這一點(diǎn),但我發(fā)現(xiàn)了一些解決方法.基本上我已經(jīng)用 @SmallTest 注釋對(duì)快速測(cè)試進(jìn)行了注釋,并使用 InstrumentationTestRunner 的自定義子類我能夠只運(yùn)行它們而不是整個(gè)套件.

您可以在this gist中找到示例代碼.

I have an Android/Gradle project. Whenever I want to run tests, I run:

./gradlew connectedInstrumentTest

which runs all my tests under the test folder of my project.

My test folder has several automation tests as well as non-automation tests. I'm mostly interested in running the fast non-automation tests without the slow automation tests.

Is there a way to run just a specific set of tests, such as from one specific class or anything similar? I'm basically asking about any kind of separation so that I can choose to run just a few tests when I want to.


Created a sample project here.

Edit local.properties to point at your Android SDK.

Next, start up an emulator or connect a phone to your computer. Then you can run tests using ./gradlew connectedInstrumentTest --info. This runs all tests.

What I am unable to figure out is how to only run tests in, say, one class and not all tests.

解決方案

Since Android Gradle Plugin 1.3.0

Starting from version 1.3.0 you can (finally!) specify the arguments the Android Gradle Plugin have to pass to the InstrumentationTestRunner.

For example, if you want to run only the tests annotated with @SmallTest and ignore the others:

android {
  //....
  defaultConfig {
  //....
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    testInstrumentationRunnerArgument "size", "small"
  }
}


Old workaround Prior to plugin 1.3.0 is not possible to do that but I've found a little workaound. Basically I've annotated with the @SmallTest annotation the fast tests and using a custom subclass of the InstrumentationTestRunner I'm able to run just them and not the whole suite.

You can found the example code in this gist.

這篇關(guān)于有沒有辦法只在 Android Gradle 項(xiàng)目中運(yùn)行一組特定的儀器測(cè)試?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出現(xiàn) IncompatibleClassChangeError)
How to get current flavor in gradle(如何在 gradle 中獲取當(dāng)前風(fēng)味)
How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修復(fù)“意外元素lt;查詢gt;在“清單中找到錯(cuò)誤?)
Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多風(fēng)味庫的多風(fēng)味應(yīng)用)
Android dependency has different version for the compile and runtime(Android 依賴在編譯和運(yùn)行時(shí)有不同的版本)
Transitive dependencies for local aar library(本地 aar 庫的傳遞依賴)
主站蜘蛛池模板: 消泡剂-水处理消泡剂-涂料消泡剂-切削液消泡剂价格-东莞德丰消泡剂厂家 | 无线联网门锁|校园联网门锁|学校智能门锁|公租房智能门锁|保障房管理系统-KEENZY中科易安 | 华禹护栏|锌钢护栏_阳台护栏_护栏厂家-华禹专注阳台护栏、楼梯栏杆、百叶窗、空调架、基坑护栏、道路护栏等锌钢护栏产品的生产销售。 | 计算机毕业设计源码网| 可程式恒温恒湿试验箱|恒温恒湿箱|恒温恒湿试验箱|恒温恒湿老化试验箱|高低温试验箱价格报价-广东德瑞检测设备有限公司 | 耐磨陶瓷,耐磨陶瓷管道_厂家-淄博拓创陶瓷科技 | 上海软件开发-上海软件公司-软件外包-企业软件定制开发公司-咏熠科技 | 电伴热系统施工_仪表电伴热保温箱厂家_沃安电伴热管缆工业技术(济南)有限公司 | 棉服定制/厂家/公司_棉袄订做/价格/费用-北京圣达信棉服 | 蓄电池回收,ups电池后备电源回收,铅酸蓄电池回收,机房电源回收-广州益夫铅酸电池回收公司 | 智能电表|预付费ic卡水电表|nb智能无线远传载波电表-福建百悦信息科技有限公司 | 房屋质量检测-厂房抗震鉴定-玻璃幕墙检测-房屋安全鉴定机构 | 实验室pH计|电导率仪|溶解氧测定仪|离子浓度计|多参数水质分析仪|pH电极-上海般特仪器有限公司 | 螺杆真空泵_耐腐蚀螺杆真空泵_水环真空泵_真空机组_烟台真空泵-烟台斯凯威真空 | 茅茅虫AI论文写作助手-免费AIGC论文查重_写毕业论文降重 | 苏州西朗门业-欧盟CE|莱茵UL双认证的快速卷帘门品牌厂家 | 云南成人高考网| 立式矫直机_卧式矫直机-无锡金矫机械制造有限公司 | 铝机箱_铝外壳加工_铝外壳厂家_CNC散热器加工-惠州市铂源五金制品有限公司 | 高温高压釜(氢化反应釜)百科| 多物理场仿真软件_电磁仿真软件_EDA多物理场仿真软件 - 裕兴木兰 | 急救箱-应急箱-急救包厂家-北京红立方医疗设备有限公司 | 砂尘试验箱_淋雨试验房_冰水冲击试验箱_IPX9K淋雨试验箱_广州岳信试验设备有限公司 | 通风天窗,通风气楼,屋顶通风天窗,屋顶通风天窗公司 | 深圳网站建设-高端企业网站开发-定制网页设计制作公司 | 游泳池设计|设备|配件|药品|吸污机-东莞市太平洋康体设施有限公司 | 消泡剂_水处理消泡剂_切削液消泡剂_涂料消泡剂_有机硅消泡剂_广州中万新材料生产厂家 | 北京网站建设|北京网站开发|北京网站设计|高端做网站公司 | 依维柯自动挡房车,自行式国产改装房车,小型房车价格,中国十大房车品牌_南京拓锐斯特房车 - 南京拓锐斯特房车 | 微量水分测定仪_厂家_卡尔费休微量水分测定仪-淄博库仑 | 保温杯,儿童婴童奶瓶,运动水壶「广告礼品杯定制厂家」超朗保温杯壶 | 流程管理|流程管理软件|企业流程管理|微宏科技-AlphaFlow_流程管理系统软件服务商 | 铸铝门厂家,别墅大门庭院大门,别墅铸铝门铜门[十大品牌厂家]军强门业 | 不锈钢水箱生产厂家_消防水箱生产厂家-河南联固供水设备有限公司 | 间甲酚,间甲酚厂家-山东祥东新材料| 传动滚筒_厂家-淄博海恒机械制造厂 | 特种电缆厂家-硅橡胶耐高温电缆-耐低温补偿导线-安徽万邦特种电缆有限公司 | 森旺-A级防火板_石英纤维板_不燃抗菌板装饰板_医疗板 | 杰恒蠕动泵-蠕动泵专业厂家-19年专注蠕动泵 | 网架支座@球铰支座@钢结构支座@成品支座厂家@万向滑动支座_桥兴工程橡胶有限公司 | 台式核磁共振仪,玻璃软化点测定仪,旋转高温粘度计,测温锥和测温块-上海麟文仪器 |