android - 为 Android 中的单个测试添加拆卸块
问题描述
在 iOS 中,存在一个可以添加到调用的单独测试中的撕裂块,addTearDownBlock
并将其放在单个测试中,它只会针对该单个测试执行。
android有类似的版本吗?
解决方案
android 中的单元测试是使用称为 JUnit 的 xUnit 变体完成的。如果您使用的是 JUnit 4.0,请使用以下注解:
@AfterClass //Will only execute once after all the tests in the class have exhausted
@After //Will run after every test
如果您使用的是 JUnit 5.0,请使用以下注释:
@AfterEach //Will run after every test
@AfterAll //Will only execute once after all the tests in the class have exhausted
推荐阅读
- javascript - 试图将我的 JavaScript 转换为 JQuery
- angular - 用于本地、QA 和产品的单一角度的 dist 构建。从外部属性文件中读取 base_url
- python-3.x - 编写一个函数来确定提供的字符串是否表示正确分隔的 Python 字符串文字
- python - YOLOv3-tensorflow 不收敛
- mysql - 从多个依赖表中删除行时出错
- python-3.6 - socket.error: [Errno 98] 地址已在使用中
- python - 无法创建包含(魔兽世界)种族和每个种族的可玩类的 JSON 有效负载
- firebase - 如何在所有数据库实例上触发firebase函数而不是默认一个?
- vue.js - Vue.Draggable 不允许我在列表之间移动项目
- fortran - 为什么我必须为 Fortran 中函数的双精度返回值隐式指定?