开发规范


默认页面

<p>微服务测试 service测试</p> <p>import org.junit.Test; import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; /**</p> <ul> <li>@author: Leomond</li> <li>@date: 2018/10/13 下午11:02 */ @RunWith(SpringRunner.class) @SpringBootTest public class RaindropServiceTest { private static final Logger LOGGER = LoggerFactory.getLogger(RaindropServiceTest.class); @Resource private RaindropService service; @Test public void test2() { String id = service.transIDO(); // Assert.assertEquals(&quot;2018&quot;, id); LOGGER.info(id); } }</li> </ul> <p>controller测试</p> <p>import org.junit.Test; import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.result.MockMvcResultHandlers; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; /**</p> <ul> <li>@author: Leomond</li> <li>@date: 2018/10/13 下午10:27 */ @RunWith(SpringRunner.class) @SpringBootTest @AutoConfigureMockMvc public class RaindropControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(RaindropControllerTest.class); @Autowired private MockMvc mvc; @Test public void test1() throws Exception { //mock进行模拟 MvcResult result = mvc.perform(MockMvcRequestBuilders.get(&quot;/idWorker&quot;)) .andExpect(MockMvcResultMatchers.status().isOk()) .andDo(MockMvcResultHandlers.print()) .andReturn(); LOGGER.info(result.getResponse().getContentAsString()); } } dubbo service测试 import com.ailk.ecs.raindrop.Raindrop; import com.alibaba.dubbo.config.annotation.Reference; import org.junit.Test; import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; /**</li> <li>@author: Leomond</li> <li>@date: 2018/10/16 下午7:37 */ @RunWith(SpringRunner.class) @SpringBootTest public class RaindropImplTest { private static final Logger LOGGER = LoggerFactory.getLogger(RaindropImplTest.class); @Reference private Raindrop raindrop; @Test public void transIDO() { String s = raindrop.transIDO(); LOGGER.info(s); } @Test public void busiOrderId() { } @Test public void trxId() { } @Test public void idWorker() { } }</li> </ul>

页面列表

ITEM_HTML