🎨 重构部分单元测试代码

This commit is contained in:
Binary Wang 2020-08-23 23:32:07 +08:00
parent b5956fb298
commit 2797bd657a
4 changed files with 15 additions and 14 deletions

View File

@ -38,24 +38,24 @@ public class WxCpChatServiceImplTest {
}
@Test
public void testChatCreate() throws Exception {
final String result = cpService.getChatService().chatCreate("测试群聊", userId,
public void testCreate() throws Exception {
final String result = cpService.getChatService().create("测试群聊", userId,
Arrays.asList(userId, userId), chatId);
assertThat(result).isNotEmpty();
assertThat(result).isEqualTo(chatId);
}
@Test
public void testChatGet() throws Exception {
WxCpChat chat = this.cpService.getChatService().chatGet(chatId);
public void testGet() throws Exception {
WxCpChat chat = this.cpService.getChatService().get(chatId);
System.out.println(chat);
Assert.assertEquals(chat.getName(), "测试群聊");
}
@Test
public void testChatUpdate() throws Exception {
this.cpService.getChatService().chatUpdate(chatId, "", "", Arrays.asList("ZhengWuYao"), null);
WxCpChat chat = this.cpService.getChatService().chatGet(chatId);
public void testUpdate() throws Exception {
this.cpService.getChatService().update(chatId, "", "", Arrays.asList("ZhengWuYao"), null);
WxCpChat chat = this.cpService.getChatService().get(chatId);
System.out.println(chat);
Assert.assertEquals(chat.getUsers().size(), 3);
}

View File

@ -1,9 +1,12 @@
package me.chanjar.weixin.cp.api;
package me.chanjar.weixin.cp.api.impl;
import com.google.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.fs.FileUtils;
import me.chanjar.weixin.cp.api.ApiTestModule;
import me.chanjar.weixin.cp.api.WxCpGroupRobotService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.article.NewArticle;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Guice;
@ -23,8 +26,7 @@ import static org.testng.Assert.*;
*/
@Slf4j
@Guice(modules = ApiTestModule.class)
public class WxCpGroupRobotServiceTest {
public class WxCpGroupRobotServiceImplTest {
@Inject
protected WxCpService wxService;

View File

@ -40,7 +40,7 @@ public class WxCpTagServiceImplTest {
@Test
public void testCreate() throws Exception {
this.tagId = this.wxService.getTagService().create("测试标签" + System.currentTimeMillis());
this.tagId = this.wxService.getTagService().create("测试标签" + System.currentTimeMillis(), null);
System.out.println(this.tagId);
}

View File

@ -1,13 +1,12 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Weixin-java-tool-suite" verbose="1">
<!-- 不再维护 -->
<suite name="WxJava-suite" verbose="1">
<test name="API_Test">
<classes>
<class name="me.chanjar.weixin.cp.api.WxCpBusyRetryTest"/>
<class name="me.chanjar.weixin.cp.api.WxCpBaseAPITest"/>
<class name="me.chanjar.weixin.cp.api.WxCpMessageAPITest"/>
<class name="me.chanjar.weixin.cp.api.WxCpMessageRouterTest"/>
<class name="me.chanjar.weixin.cp.api.WxCpGroupRobotServiceTest"/>
</classes>
</test>