zoukankan      html  css  js  c++  java
  • spring boot1.5.6 测试类1

    package com.example.demo;

    import org.junit.Before;
    import org.junit.Test; 
    import org.junit.runner.RunWith; 
    import org.springframework.boot.test.context.SpringBootTest;
    import org.springframework.http.MediaType; 
    import org.springframework.test.context.junit4.SpringRunner;
    import org.springframework.test.web.servlet.MockMvc; 
    import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
    import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
    import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
    import org.springframework.test.web.servlet.setup.MockMvcBuilders; 
    import com.example.demo.controller.HelloWorldController;

    @RunWith(SpringRunner.class)
    @SpringBootTest
    public class HelloWorldControlerTests {
         private MockMvc mvc;
            @Before
            public void setUp() throws Exception {
                mvc = MockMvcBuilders.standaloneSetup(new HelloWorldController()).build();
            }
            @Test
            public void getHello() throws Exception {
            mvc.perform(MockMvcRequestBuilders.get("/sayHello").accept(MediaType.APPLICATION_JSON))
                        .andExpect(MockMvcResultMatchers.status().isOk())
                        .andDo(MockMvcResultHandlers.print())
                        .andReturn();
            }
            
            
    }

  • 相关阅读:
    css
    AcWing 145 超市 (贪心)
    AcWing 144 最长异或值路径 (Trie)
    AcWing 143 最大异或对 (Trie)
    AcWing 142 前缀统计 (Trie)
    AcWing 141 周期 (KMP)
    AcWing 139 回文子串的最大长度 (哈希+二分 / Manacher)
    AcWing 136 邻值查找 (set)
    AcWing 133 蚯蚓 (队列)
    AcWing 131 直方图中最大的矩形 (单调栈)
  • 原文地址:https://www.cnblogs.com/faunjoe88/p/7724297.html
Copyright © 2011-2022 走看看