首页 > 解决方案 > 为异步方法编写 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
                        }
                    });
    
    ......

}

标签: javajunitjunit5-extension-model

解决方案


推荐阅读