java - 为异步方法编写 Junit 测试用例
问题描述
我有一个异步方法,想编写一个单元测试用例,我将方法粘贴到这里,任何人都可以帮助为此编写测试用例..
......
public method1(string topic,string msg){
...
client.publishWith().topic(topic).payload(msg.getBytes()).qos(MqttQos.EXACTLY_ONCE).send()
.whenComplete((mqtt3Publish, throwable) -> {
if (throwable != null) {
//Some normal Code
} else {
//Some normal code
}
});
......
}
解决方案
推荐阅读
- react-native - 如何从 react-native 中的选项卡堆栈注销到身份验证?
- quickfix - MsgSeqNum 序列和不同的会话
- java - 如何初始化数组列表中的对象
- ruby-on-rails - Rails 通过 2 个键关联
- python - 安装和导入 Python 包的多个版本
- javascript - 将我的选择 ID 传递给路由控制器并显示到另一个刀片文件
- database - 对于复杂的查询,哪个更好 sql 或 mongodb?
- maven - Apache Zeppelin 不适用于 maven repo 的 https
- qt - qtRunLoggedCommand 在哪里定义?
- vue.js - 带有 BootstrapVue 可编辑表格行的 VeeValidate