Skip to content

Commit 5986698

Browse files
committed
🎨 增加点单元测试示例代码
1 parent 6d556f8 commit 5986698

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed
Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,51 @@
11
package me.chanjar.weixin.open.api.impl;
22

3+
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
4+
import me.chanjar.weixin.common.error.WxErrorException;
5+
import org.testng.annotations.BeforeTest;
36
import org.testng.annotations.Test;
47

5-
import static org.testng.Assert.*;
6-
78
/**
89
* 单元测试.
910
*
1011
* @author <a href="https://github.com/binarywang">Binary Wang</a>
1112
* @date 2020-10-19
1213
*/
1314
public class WxOpenOAuth2ServiceImplTest {
15+
private final WxOpenOAuth2ServiceImpl service = new WxOpenOAuth2ServiceImpl("123", "");
16+
17+
@BeforeTest
18+
public void init() {
19+
this.service.setWxOpenConfigStorage(new WxOpenInMemoryConfigStorage());
20+
}
1421

1522
@Test
1623
public void testBuildAuthorizationUrl() {
24+
this.service.buildAuthorizationUrl("", "", "");
1725
}
1826

1927
@Test
20-
public void testGetAccessToken() {
28+
public void testGetAccessToken() throws WxErrorException {
29+
this.service.getAccessToken("a");
2130
}
2231

2332
@Test
24-
public void testTestGetAccessToken() {
33+
public void testTestGetAccessToken() throws WxErrorException {
34+
this.service.getAccessToken("", "", "");
2535
}
2636

2737
@Test
28-
public void testRefreshAccessToken() {
38+
public void testRefreshAccessToken() throws WxErrorException {
39+
this.service.refreshAccessToken("");
2940
}
3041

3142
@Test
32-
public void testGetUserInfo() {
43+
public void testGetUserInfo() throws WxErrorException {
44+
this.service.getUserInfo(new WxOAuth2AccessToken(), "");
3345
}
3446

3547
@Test
3648
public void testValidateAccessToken() {
49+
this.service.validateAccessToken(new WxOAuth2AccessToken());
3750
}
3851
}

0 commit comments

Comments
 (0)