当前位置: 首页 > news >正文

解决 Android 单元测试 No tests found for given includes:

问题

报错:

Execution failed for task ':testDebugUnitTest'.

        > No tests found for given includes:

解决方案

1、一开始以为是没有给测试类加public修饰

2、然后替换 @Test 注解的包可以解决,将 org.junit.jupiter.api.Test 修改为 org.junit.Test

import org.junit.Test; //OKimport org.junit.jupiter.api.Test;//No use

org.junit.jupiter.api.Test是IDE 插件默认生成Test文件的引用。

两个类的实现是不一样的,介绍如下:

org.junit.jupiter.api

package org.junit.jupiter.api;@Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@API(status = STABLE, since = "5.0")
@Testable
public @interface Test {
}

org.junit

package org.junit;@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface Test {/*** Default empty exception.*/static class None extends Throwable {private static final long serialVersionUID = 1L;private None() {}}/*** Optionally specify <code>expected</code>, a Throwable, to cause a test method to succeed if* and only if an exception of the specified class is thrown by the method. If the Throwable's* message or one of its properties should be verified, the* {@link org.junit.rules.ExpectedException ExpectedException} rule can be used instead.*/Class<? extends Throwable> expected() default None.class;long timeout() default 0L;
}

Note:使用 org.junit.Test 的测试方法test要被public修饰。

后续报错

http://www.lryc.cn/news/489735.html

相关文章:

  • 人工智能的核心思想-神经网络
  • JAVA中的Lamda表达式
  • 锂电池学习笔记(一) 初识锂电池
  • 深度学习2
  • 第六节-AppScan扫描报告
  • 【c++丨STL】stack和queue的使用及模拟实现
  • 基于SpringBoot的在线教育系统【附源码】
  • Kafka-副本分配策略
  • 市场波动不断,如何自我提高交易心理韧性?
  • 加速科技精彩亮相中国国际半导体博览会IC China 2024
  • 利用c语言详细介绍下选择排序
  • 华为流程L1-L6业务流程深度细化到可执行
  • bridge-multicast-igmpsnooping
  • git使用(一)
  • Linux环境安装MongoDB
  • Cyberchef使用功能之-多种压缩/解压缩操作对比
  • TypeScript 装饰器都有那些应用场景?如何更快的上手?
  • 堆优化版本的Prim
  • Ubuntu上安装MySQL并且实现远程登录
  • 蓝桥杯每日真题 - 第21天
  • (长期更新)《零基础入门 ArcGIS(ArcMap) 》实验一(下)----空间数据的编辑与处理(超超超详细!!!)
  • NLP论文速读(CVPR 2024)|使用DPO进行diffusion模型对齐
  • 操作系统——揭开盖子
  • 如何在 React 项目中应用 TypeScript?应该注意那些点?结合实际项目示例及代码进行讲解!
  • C++学习第四天
  • 【从零开始的LeetCode-算法】3232. 判断是否可以赢得数字游戏
  • 一种简单高效的RTSP流在线检测方法,不需要再过渡拉流就可以获取设备状态以及对应音视频通道与编码格式
  • 24/11/22 项目拆解 艺术风格转移
  • 数字赋能,气象引领 | 气象景观数字化服务平台重塑京城旅游生态
  • 关于Redux的学习(包括Redux-toolkit中间件)