@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(
classes = {App.class}
)
@WebAppConfiguration
public class SpringbootTest {
private static final Log log = LogFactory.getLog(SpringbootTest.class);
@Autowired
private UserPojo userPojo;
private MockMvc mvc;

public SpringbootTest() {
}

@Before
public void setUp() throws Exception {
this.mvc = MockMvcBuilders.standaloneSetup(new Object[]{new HelloController()}).build();
}

@Test
public void getHello() throws Exception {
this.mvc.perform(MockMvcRequestBuilders.get("/first/hello1", new Object[0]).accept(new MediaType[]{MediaType.APPLICATION_JSON})).andExpect(MockMvcResultMatchers.status().is(404));
}

@Test
public void userInfo() {
Assert.assertEquals(this.userPojo.getName(), "songhuanhuan");
Assert.assertEquals(this.userPojo.getSex(), "女");
log.info("日志");
}
}
posted on 2018-06-24 01:42  米兔斯基  阅读(1167)  评论(0编辑  收藏  举报