@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("日志");
}
}

相关文章:

  • 2021-08-05
  • 2021-11-14
  • 2021-05-24
  • 2022-12-23
  • 2021-09-29
  • 2021-12-26
  • 2021-04-14
  • 2021-09-05
猜你喜欢
  • 2021-08-18
  • 2022-12-23
  • 2021-12-16
  • 2021-07-13
  • 2021-12-02
  • 2021-11-20
相关资源
相似解决方案