`

android 单元测试Test run failed: Test run failed to complete. Expected 1 tests, received 0

 
阅读更多

本人学习android不久,

今天在写弄一个单元测试的时候老是报 Test run failed: Test run failed to complete. Expected 1 tests, received 0错误,我在google中查了很多资料,有的说是得有一个空构造函数,我也这么做了,可是依然没有效果,

我一一检查是不是自己没有功能配置文件中加入:

<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="你的单元测试所在包名" android:label="Tests for My App" />,和<uses-library android:name="android.test.runner" />,自己也加入了,可就是产行,

因为我个人习惯,我把那个单元测试方法写了private权限,我一直以为这样写应该没有什么问题,在我几乎想不到是哪里有错时,我试着把那个单元测试方法的private权限改了public权限,运行一看,好了,原来问题就在这个单元测试方法不能为private权限,一定写成public权限,要不就会报Test run failed: Test run failed to complete. Expected 1 tests, received 0错误,

下面 我简单的总结一下android单元测试的一些要求吧,

1。你要实现单元测试的类必须得继承AndroidTestCast类,

2,你单元测试中的那个方法必须以Test开头:Test+你的方法名,

3,你运行这个单元测试类的方法,一定选中这个以Test开头的方法,再单击右键,选中Android JUnit Test方可,

4,在你的项目的功能配置文件中必须加入 <instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="你的单元测试所在包名" android:label="Tests for My App" />,这一行加在<application>节点外面,而<uses-library android:name="android.test.runner" />则要加在<application>里面,组件节点外面,如<Activity>节点外面,

5,你单元测试中的那个方法必须抛出异常 ,在你的方法加上:throws throwable

分享到:
评论

相关推荐

    hbase 启动regionserver日志报错: Wrong FS: hdfs:// .regioninfo, expected: file:///

    NULL 博文链接:https://bnmnba.iteye.com/blog/2322332

    Complete Guide to Test Automation - 自动化测试从策略到实战大全

    Complete Guide to Test Automation provides a detailed hands-on guide for writing highly maintainable test code. What You’ll Learn Know the real value to be expected from test automation Discover...

    BURNINTEST--硬件检测工具

    - A CD ROM + 1 Music CD or Data CD to run the CD test. - A CD-RW to run the CD burn test. - A network connection and the TCP/IP networking software installed for the Network Tests Pro version only: ...

    Complete Guide to Test Automation--2018

    Know the real value to be expected from test automation Discover the key traits that will make your test automation project succeed Be aware of the different considerations to take into account when...

    Springer.The.Developer’s.Guide.to.Debugging.2008.pdf

    3.3 Get the Debugger to Run with Your Program . . . . . . . 24 3.4 Learn to do a Stack Trace on a Program Crash . . . . . . 27 3.5 Learn to Use Breakpoints . . . . . . . . . 28 3.6 Learn to Navigate ...

    官方资料:Oracle 11g中的信息集成.pdf

    官方资料:Oracle 11g中的信息集成 数据集成技术路线图;数据迁移技术;数据联合技术;数据库网关;数据复制技术;流技术:体系架构;ELT技术;OWB;数据清洗;匹配-合并;数据对象设计-统一编辑器;...

    Android程序技术:调试.pptx

    使用AndroidStudio开发工具完成单元测试非常简单,在项目创建时Android Studio就已经默认创建了一个androidTest包和ApplicationTest类,所有测试的功能模块写入此类即可。 单元测试 单元测试 单元测试 在Application...

    Android代码-uri-differ

    Simple lib to find diffs between URI and represent it in pretty way. Quick start: Use maven: ru.lanwen.diff uri-differ-lib 1.3.0 Add some code: Get changes: UriDiff changes = UriDiffer.diff() ....

    EurekaLog_7.5.0.0_Enterprise

    1)....Added "ECC32TradeSpeedForMemory" option - defaults to 0/False, could be changed to 1 via Custom/Manual tab. This option will switch from fast-methods to slower methods, but which take less ...

    Qt单元测试演示qt单元测试demo_基于qt5单元测试工程例子qt5单元测试例子

    //qt单元测试用法,qt测试例子,qt单元测试demo,qt单元测试简单例子,qt单元测试例程,qt单元测试简单例子, qt5单元测试例子,qt5单元测试代码,qt5单元测试工程例子,测试运行ok //首先,用标准的qt测试单元导向,...

    Elasticsearch.A.Complete.Guide.epub

    Some development experience is expected. What You Will Learn Install and configure Elasticsearch, Logstash, and Kibana Write CRUDE operations and other search functionalities using the Elasticsearch...

    dubbo-monitor-simple.zip

    dubbo-monitor监控中心,基于alibaba dubbo.jar开发,解决Decode rpc invocation failed: expected map/object at java.lang.String (Ljava/lang/String)、com.alibaba.dubbo.common.URL' could not be instantiated...

    httptest:一个简单的并发HTTP测试工具

    request : # Request to send path : ' / ' # Path response : # Expected response statusCodes : [200] # List of expected response status codes 在本地运行测试 该程序作为Docker映像分发。 要在本地运行...

    Delphi 2010 Handbook Feb 2010

    Chapter 1: A Better IDE..........................................19 Chapter 2: The Debugger........................................47 Chapter 3: Extended RTTI and Attributes..............................

    解决Tensorflow2.0 tf.keras.Model.load_weights() 报错处理问题

    4、模型报错:ValueError: You are trying to load a weight file containing 12 layers into a model with 0 layers. 问题分析: 模型创建后还没有编译,一般是在模型加载前调用model.build(input_shape), 但我通过...

    Test-Core:一次导入即可进行现代Perl测试

    Test :: Core-一次导入即可进行现代Perl测试 版本 版本0.0200 概要 use Test::Core; # Your tests here done_testing 描述 Test :: Core通过一次简单易用的导入提供了Modern Perl的最佳测试工具。 它建立在基础上,...

    Python Testing_ Beginner’s Guide.pdf

    Chapter 1: Testing for Fun and Profit introduces Python test-driven development and various testing methods. Chapter 2: Doctest: The Easiest Testing Tool covers the doctest tool and teaches you how ...

Global site tag (gtag.js) - Google Analytics