zoukankan      html  css  js  c++  java
  • springboot测试的方法

    @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("日志");
    }
    }
  • 相关阅读:
    c++ 迷宫问题
    linux下恢复删除的文件
    c++ 分解数2
    c++ 平分石头
    多态
    设计模式中类的6种关系
    工厂方法模式
    设计原则之面向接口编程
    封装、继承
    便利构造器、单件模式
  • 原文地址:https://www.cnblogs.com/metu/p/9219445.html
Copyright © 2011-2022 走看看