加入springboot测试依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
test
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class LawsApplicationTests {
private MockMvc mockMvc;
@Autowired
private WebApplicationContext webApplicationContext;
@Autowired
private PermissionMenuService permissionMenuService;
@Before
public void setUp() throws Exception {
this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
}
@Test
public void test(){
List<PermissionMenu> list = permissionMenuService.list();
for (PermissionMenu pm : list) {
System.out.println(pm.toString());
}
}
@Test
public void test2() throws Exception {
mockMvc.perform(MockMvcRequestBuilders
.get("/permission-menu/freeMarker/ftl")
);
}
}