🎨 重构部分单元测试代码

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 @Test
public void testChatCreate() throws Exception { public void testCreate() throws Exception {
final String result = cpService.getChatService().chatCreate("测试群聊", userId, final String result = cpService.getChatService().create("测试群聊", userId,
Arrays.asList(userId, userId), chatId); Arrays.asList(userId, userId), chatId);
assertThat(result).isNotEmpty(); assertThat(result).isNotEmpty();
assertThat(result).isEqualTo(chatId); assertThat(result).isEqualTo(chatId);
} }
@Test @Test
public void testChatGet() throws Exception { public void testGet() throws Exception {
WxCpChat chat = this.cpService.getChatService().chatGet(chatId); WxCpChat chat = this.cpService.getChatService().get(chatId);
System.out.println(chat); System.out.println(chat);
Assert.assertEquals(chat.getName(), "测试群聊"); Assert.assertEquals(chat.getName(), "测试群聊");
} }
@Test @Test
public void testChatUpdate() throws Exception { public void testUpdate() throws Exception {
this.cpService.getChatService().chatUpdate(chatId, "", "", Arrays.asList("ZhengWuYao"), null); this.cpService.getChatService().update(chatId, "", "", Arrays.asList("ZhengWuYao"), null);
WxCpChat chat = this.cpService.getChatService().chatGet(chatId); WxCpChat chat = this.cpService.getChatService().get(chatId);
System.out.println(chat); System.out.println(chat);
Assert.assertEquals(chat.getUsers().size(), 3); 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 com.google.inject.Inject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.fs.FileUtils; 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 me.chanjar.weixin.cp.bean.article.NewArticle;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Guice; import org.testng.annotations.Guice;
@ -23,8 +26,7 @@ import static org.testng.Assert.*;
*/ */
@Slf4j @Slf4j
@Guice(modules = ApiTestModule.class) @Guice(modules = ApiTestModule.class)
public class WxCpGroupRobotServiceTest { public class WxCpGroupRobotServiceImplTest {
@Inject @Inject
protected WxCpService wxService; protected WxCpService wxService;

View File

@ -40,7 +40,7 @@ public class WxCpTagServiceImplTest {
@Test @Test
public void testCreate() throws Exception { 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); System.out.println(this.tagId);
} }

View File

@ -1,13 +1,12 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <!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"> <test name="API_Test">
<classes> <classes>
<class name="me.chanjar.weixin.cp.api.WxCpBusyRetryTest"/> <class name="me.chanjar.weixin.cp.api.WxCpBusyRetryTest"/>
<class name="me.chanjar.weixin.cp.api.WxCpBaseAPITest"/> <class name="me.chanjar.weixin.cp.api.WxCpBaseAPITest"/>
<class name="me.chanjar.weixin.cp.api.WxCpMessageAPITest"/> <class name="me.chanjar.weixin.cp.api.WxCpMessageAPITest"/>
<class name="me.chanjar.weixin.cp.api.WxCpMessageRouterTest"/> <class name="me.chanjar.weixin.cp.api.WxCpMessageRouterTest"/>
<class name="me.chanjar.weixin.cp.api.WxCpGroupRobotServiceTest"/>
</classes> </classes>
</test> </test>