dbb4dc30
张志伟
|
1
|
package cn.fw.valhalla;
|
a4ec6faa
张志伟
|
2
|
|
f424423f
张志伟
|
3
|
import cn.fw.common.util.ValidationUtils;
|
a4ec6faa
张志伟
|
4
5
6
7
8
9
10
11
12
13
|
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
a4ec6faa
张志伟
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {ValhallaApplication.class})
@AutoConfigureMockMvc
class ValhallaAppTests {
private final MockMvc mvc;
@Autowired
ValhallaAppTests(final MockMvc mvc) {
this.mvc = mvc;
}
@Test
public void exampleTest() throws Exception {
|
46885b83
张志伟
📝 编写测试类
|
30
|
this.mvc.perform(
|
eef76d3f
张志伟
feature(*): 修复bug
|
31
32
33
|
get("/app/accident/demo")
.header("Authorization", "4B70342B7CC9709C7D76A982217570ADB407D23ECDC0763C4AD3F5D069B8DEB33C5FCE9E493D9F6DE05D532E7A8B5DD1")
.param("val", "12345"))
|
a4ec6faa
张志伟
|
34
|
.andExpect(status().isOk())
|
a4ec6faa
张志伟
|
35
36
37
|
.andDo(MockMvcResultHandlers.print());
}
|
f424423f
张志伟
|
38
39
|
@Test
public void phoneTest() {
|
eef76d3f
张志伟
feature(*): 修复bug
|
40
|
String phone = "+8619142820251";
|
f424423f
张志伟
|
41
42
|
System.out.println(ValidationUtils.checkMobile(phone));
}
|
a4ec6faa
张志伟
|
43
|
}
|